IBM Data and AI

Welcome to the IBM Data and AI Ideas Portal for Clients!

We welcome and appreciate your feedback on IBM Data and AI Products to help make them even better than they are today!
Before you submit an idea, please perform a search first as a similar idea may have already been reported in the portal. If a related idea is not yet listed, please create a new idea and include with it a description which includes expected behavior as well as why having this feature would improve the service and how it would address your use case.
IBM Employees:
Clients:
  • Our team welcomes any feedback and suggestions you have for improving our offerings / products! This forum allows us to connect your offering / product improvement ideas with IBM product and engineering teams.

  • If you have not registered on this portal please click on the following link and register. To complete registration you will need to open the email you will receive from Aha to confirm your identity. http://ibm.biz/IBM-Data-and-AI-Portal-Register

Additional Information:
  • The shorter URL for this site is: https://ibm.biz/IBM-Data-and-AI-Ideas

  • To view our roadmaps: http://ibm.biz/Data-and-AI-Roadmaps

  • Reminder: This is not the place to submit defects or support needs, please use normal support channel for these cases

  • Please do not use the Ideas Portal for reporting bugs - we ask that you report bugs or issues with the product by contacting IBM support.

Allow SELECT INTO to assign query results to Local Variables within a Function/Procedure

When trying to assign a query result to local variables within a PROCEDURE or FUNCTION using Dynamic SQL only a DYNAMIC CURSOR (see below) can be used which leads to more complicated and lengthy code. However, using SELECT INTO (see below) could be used to accomplish the same value to local variable assignment in fewer steps. Our request is to allow the use of SELECT INTO with Dynamic SQL for local variable assignment as is allowed in other RDBMSs.

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Aug 19 2020
  • Future consideration
Who would benefit from this IDEA? As a customer, I want to be able to use SELECT INTO and Dynamic SQL to assign query result values to Local Variables to improve the readability and supportability of my code.
How should it work?

In the example below, I show how we currently use Dynamic SQL with a CURSOR (what we call a DYNAMIC CURSOR) to assign a query result to a Local Variable and how we would like it to be accomplished via SELECT INTO with Dynamic SQL as well as the error thrown when using the SELECT INTO approach.

Example:
--DYNAMIC CURSOR
--Get v_stored_procedure_execution_id

SET v_str_sql_cursor = 'SELECT ' || v_process_database_name || '.SEQ_DATAPIPELINE_PROCESS_H0.NEXTVAL FROM ' || v_process_database_name || '.DUMMY;';

PREPARE c_table

FROM v_str_sql_cursor;

OPEN c_table_cursor USING v_process_database_name;

FETCH c_table_cursor INTO v_stored_procedure_execution_id;

CLOSE c_table_cursor;

ERROR RETURNED:

NONE


--
SELECT INTO
--Get v_stored_procedure_execution_id

SET v_str_sql = 'SELECT ' || v_process_database_name || '.SEQ_DATAPIPELINE_PROCESS_H0.NEXTVAL INTO :v_stored_procedure_execution_id FROM ' || v_process_database_name || '.DUMMY;';

EXECUTE IMMEDIATE v_str_sql;

ERROR RETURNED:

SQL Error [42610]: The statement was not processed because the statement contains an invalid use of one of the following: an untyped parameter marker, the DEFAULT keyword, or a null value.. SQLCODE=-418, SQLSTATE=42610, DRIVER=4.26.14

Idea Priority Medium
Priority Justification As a customer, I want to be create SOLID code and we believe that is best done by using SELECT INTO with Dynamic SQL to assign values from a query result to Local Variables with a FUNCTION/PROCEDURE.
Customer Name O'Reilly Auto Parts
  • Attach files

NOTICE TO EU RESIDENTS: per EU Data Protection Policy, if you wish to remove your personal information from the IBM ideas portal, please login to the ideas portal using your previously registered information then change your email to "anonymous@euprivacy.out" and first name to "anonymous" and last name to "anonymous". This will ensure that IBM will not send any emails to you about all idea submissions