DB2 Server for VSE & VM: Interactive SQL Guide and Reference


Starting a Stored Statement That Contains Placeholders

First, store a statement that contains placeholders. Type:

   hold select &1 -
   from &2 -
   where &3
 
   store myquery

Now start the statement, and add parameters to complete it. Type:

   start myquery (* employee empno='000010')

This produces the following statement:

   select * from employee where empno='000010'

and displays Figure 41.

Figure 41. A Query Result from Starting a Stored Statement with Placeholders

+--------------------------------------------------------------------------------+
| EMPNO   FIRSTNME      MIDINIT  LASTNAME         WORKDEPT  PHONENO  HIREDATE    |
| ------  ------------  -------  ---------------  --------  -------  ----------  |
| 000010  CHRISTINE     I        HAAS             A00       3978     1965-01-01  |
| * End of Result *** 1 Rows Displayed ***Cost Estimate is 1*********************|
+--------------------------------------------------------------------------------+
Note:A message is displayed, indicating that any formatting performed while viewing this query result is not saved. This condition is explained in detail in Saving the Format Information.

Because the placeholders are replaced by the parameters when the statement is processed, the stored SQL statement remains unchanged and can be reused.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]