Running SQL statements from screen input

You can specify free-form SQL statements on your screen and run them dynamically.

Procedure

To run SQL statements from screen input:

  1. On the DB2 Administration Menu (ADB2) panel, specify option 2, and press Enter.
  2. On the Execute SQL Statements (ADB22) panel, specify option 1, and press Enter:
     ADB22 min -------------------- Execute SQL Statements ------------------- 01:36
     Option ===> 1                                                                  
                                                                                    
        1 - Edit/run SQL statements                           DB2 System: DD1A      
        2 - Run or Explain SQL statements                     DB2 SQL ID: ADM001     
        3 - Build SQL SELECT, INSERT, UPDATE or DELETE prototype                    
        4 - Create/drop/label/comment on objects                                    
        5 - Grant/revoke privileges on objects
  3. On the Edit/Run SQL Statement (ADBPMESQ) panel, enter the SQL statement that you want to run between columns 1 and 72 by using ISPF edit commands. Do not use line numbers. If you want a line to be ignored, start that line with the SQL comment characters (--).

    By default, any SQL statement that you enter is converted to uppercase. To disable this behavior, specify the CAPS OFF primary command.

     ADBPMESQ  ------------ Edit/Run SQL Statement ------------ Columns 00001 00072  
     Command ===>                                                  Scroll ===> CSR   
                                                                                     
     ****** ***************************** Top of Data ****************************** 
     ==MSG> Use command EXEC to run the SQL statement and return to the edit session 
     ==MSG> or use command CANCEL to exit the edit session without running the SQL   
     ''''''                                                                          
     ''''''                                                                          
     ''''''                                                                          
     ''''''                                                                          
     ''''''                                                                          
     ''''''                                                                          
     ''''''                                                                          
     ''''''                                                                          
     ''''''                                                                          
     ****** **************************** Bottom of Data ****************************
  4. Run the statement by taking one of the following actions:
    • Enter the EXEC primary command. Use this command if you want to return to the edit panel after you run the statement.
    • Press PF3. Use PF3 if you want to end the session after you run the statement. The statement is saved in a temporary data set. If you did not make any changes to the statement, you are prompted whether you want to run the statement.

    If you do not want to save or run the statement, use the CANCEL command.

    If an SQL SELECT statement returns rows, the result is shown on the default table display panel.

    After the SQL statement is run, a message is displayed on the top left side of the panel to say that the statement was executed. For example:

    ADB22 min -------------------- Execute SQL Statements ------------------- 16:30
    Option ===>                                                                    
    INSERT stmt executed                                                           
       1 - Edit/run SQL statements                           DB2 System: DD1A      
       2 - Run or Explain SQL statements                     DB2 SQL ID: ADM001    
       3 - Build SQL SELECT, INSERT, UPDATE or DELETE prototype                    
       4 - Create/drop/label/comment on objects                                    
       5 - Grant/revoke privileges on objects                                      
    While this message is displayed, press PF1 to see any additional information. For UPDATE, INSERT, and DELETE statements, the number of affected rows is displayed. For example:
    ADB260I 1 row(s) affected by the INSERT statement