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


Changing a Stored Statement

Changes can be made to a stored SQL statement using the CHANGE command discussed earlier in this chapter under Changing the Current SQL Statement. For example, to change the ORDER BY clause in the statement stored as DEPT, perform the following:

  1. Use the RECALL command to display the stored statement. Type:

       recall dept
    

    The recalled statement appears as:

       SELECT DEPTNO,MGRNO FROM DEPARTMENT ORDER BY MGRNO
    
  2. For this example, change the ORDER BY feature to the DEPTNO column. Type:
       change /by mgrno/by deptno/
    

    The changed statement is displayed as:

       SELECT DEPTNO,MGRNO FROM DEPARTMENT ORDER BY DEPTNO
    
  3. Now, store the changed SELECT statement as DEPT2:
       store dept2
    
  4. To verify the new statement, use the RECALL command:
       recall dept2
    

If you look at the query results of DEPT and DEPT2, you will notice that the FORMAT information is maintained. As long as the statement to be changed or stored contains an unchanged SELECT or FROM clause, FORMAT information is saved.


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