Skip to Main Content
IBM Power Ideas Portal


This portal is to open public enhancement requests against IBM Power Systems products, including IBM i. To view all of your ideas submitted to IBM, create and manage groups of Ideas, or create an idea explicitly set to be either visible by all (public) or visible only to you and IBM (private), use the IBM Unified Ideas Portal (https://ideas.ibm.com).


Shape the future of IBM!

We invite you to shape the future of IBM, including product roadmaps, by submitting ideas that matter to you the most. Here's how it works:

Search existing ideas

Start by searching and reviewing ideas and requests to enhance a product or service. Take a look at ideas others have posted, and add a comment, vote, or subscribe to updates on them if they matter to you. If you can't find what you are looking for,

Post your ideas
  1. Post an idea.

  2. Get feedback from the IBM team and other customers to refine your idea.

  3. Follow the idea through the IBM Ideas process.


Specific links you will want to bookmark for future use

Welcome to the IBM Ideas Portal (https://www.ibm.com/ideas) - Use this site to find out additional information and details about the IBM Ideas process and statuses.

IBM Unified Ideas Portal (https://ideas.ibm.com) - Use this site to view all of your ideas, create new ideas for any IBM product, or search for ideas across all of IBM.

ideasibm@us.ibm.com - Use this email to suggest enhancements to the Ideas process or request help from IBM for submitting your Ideas.

Status Future consideration
Workspace IBM i
Categories Db2 for i
Created by Guest
Created on May 15, 2024

Named parameters for SQL insert statement.

Db2 for i has in few occasions been a forerunner for features of SQL. So perhaps this idea could also be one of these features.


We have used named parameters for UDTF and stored procedures for quite some time.


SELECT *

FROM TABLE (QSYS2.IFS_OBJECT_STATISTICS(

START_PATH_NAME => '/usr',

SUBTREE_DIRECTORIES => 'NO'

) );



This idea will implement the same syntax for the SQL insert statements.


Particularly useful in combination with complex insert statements.


Example


CREATE TABLE TEST (MYNUMBER INT , MYNAME VARCHAR(256));


Here is the classical insert statement:


INSERT INTO TEST (MYNUMBER , MYNAME) VALUES(1, ‘JOHN’);


With this new idea, we could rewrite the statement to look like this:


INSERT INTO TEST (

MYNUMBER => 1 ,

MYNAME =>’JOHN’

);


At a first glance, it looks like syntactic sugar however the benefit is more obvious for more complex insert statements like this:


INSERT INTO TEST (

MYNUMBER => (SELECT COUNT(*) FROM SERVICES_INFO),

MYNAME => (SELECT MAX(NAME) FROM SERVICES_INFO)

);


Or even more clear when inserting multiple rows where default values are required:


INSERT INTO TEST

( MYNUMBER => (SELECT COUNT(*) FROM SERVICES_INFO)),

( MYNAME => (SELECT MAX(NAME) FROM SERVICES_INFO));


The above example would insert two rows where the first row will contain the result of an SQL query in MYNUMBER and leaving MYNAME the default value.


The next row would leave the MYNUMBER a default value, and MYNAME will contain the result of SQL query (or value or function call)


Perhaps the best feature of this new idea will be when you have a large number of columns to insert in one single statement. The readability of the insert statement would be much easier. It will be more obvious which data goes into which column that today can be quite painful.


INSERT INTO TABLE_WITH_LOADS_OF_COLUMNS (A,B,C,D,E,F,G,H,I)

VALUES ( 1, 2, 3, 4, 5, 6, 7, 8) ;


Did you spot the error? Here we are designating nine columns from A to I however only inserting eight values. It can be painful to spot these kind of errors.


Let's rewrite this statement that gives us no opportunity to make mistakes:


INSERT INTO TABLE_WITH_LOADS_OF_COLUMNS

VALUES ( A=>1, B=>2, C=> 3,D=> 4,E=> 5, F=>6, G=>7 , H=>8 ) ;


This feature should of course, also support parameter marker and host variables:


INSERT INTO TEST (

MYNUMBER => :MYNUMBER,

MYNAME => :MYNAME

);



Idea priority High
  • Admin
    Carmelita Ruvalcaba Cevallos
    Reply
    |
    Jun 25, 2024

    The CAAC has reviewed this IBM Idea and recommends that IBM view this as a medium priority Idea that should be addressed.

    This will be an interesting extension to the language.

    Background: The COMMON Americas Advisory Council (CAAC) members have a broad range of experience in working with small and medium-sized IBM i customers. CAAC has a key role in working with IBM i development to help assess the value and impact of individual IBM Ideas on the broader IBM i community and has therefore reviewed your Idea.

    For more information about CAAC, see www.common.org/caac

    Carmelita Ruvalcaba - CAAC Program Manager

  • Guest
    Reply
    |
    Jun 12, 2024
    IBM will use this Idea as input to planning, but no commitment is made or implied. This Idea will be updated in the future if IBM implements it.

    Db2 for i development team
    IBM Power Systems Development