There are two ways to change the syntax of an existing SQL statement in DB/Assist:
•Edit the syntax in the SQL Editor window.
•Edit the syntax by using the statement construction dialog boxes.
Editing in the SQL Editor Window
To edit the statement syntax in the SQL Editor window.
1.Open the SAM that includes this statement, as described in Opening an Existing SAM.
2.Open the SQL statement, as described in Opening an Existing SQL Statement to display the syntax of the SQL statement in the SQL Editor window.
3.Edit the syntax directly in the SQL Editor window by using the Cut, Copy, Paste, and Undo push buttons to help you construct the statement.
4.Select the Validate push button to check whether the statement syntax is correct according to DB2.
The SQL Statement button bar and corresponding menu choices become enabled.
DB/Assist displays a message box indicating that the syntax is correct or that there is an error.
If an error message appears, type the correct syntax in the SQL Editor window. Do not attempt to correct the syntax by using the DB/Assist dialog boxes to rebuild the statement.
5.Select the OK push button in the message box
6.If necessary, repeat Steps 3 through 5 to correct the syntax error and re-validate the statement.
Resolving Ambiguous Statement
If you create a SQL statement as one type in the New SQL Statement dialog box, and then change this type when you edit its syntax in the SQL Editor window, it is possible to create an ambiguous statement for which DB/Assist cannot determine the correct type.
This occurs, for example, if you type an UPDATE or DELETE statement in the SQL Editor window without a WHERE or WHERE CURRENT OF clause, and then try to validate or run this statement. In this situation, DB/Assist cannot determine whether the statement is searched or positioned.
To resolve this, DB/Assist displays the Ambiguous Statement dialog box, in which you must specify whether the statement is searched or positioned.
For information about completing the Ambiguous Statement dialog box, see Typing a Statement in the SQL Editor Window.
Editing with the Statement Construction Dialog Boxes
To edit the statement using the statement construction dialog boxes, follow these steps:
1.Open the SAM that includes this statement, as described in Opening an Existing SAM.
2.Open the SQL statement, as described in Section Opening an Existing SQL Statement.
The syntax of the SQL statement appears in the SQL Editor window.
3.Select SQL Statement Ø Tables or the Tables button.
The completed statement construction dialog box for your statement appears.
4.Edit the information in the dialog box.
For information about completing the statement construction dialog boxes, see the appropriate section in Building SQL Statements.
7.Select the OK push button.
DB/Assist automatically validates the syntax for this statement and updates it in the SQL Editor window.
8.If appropriate, complete additional statement construction dialog boxes to add computed columns, WHERE clauses, join clauses, GROUP BY clauses, and ORDER BY clauses to your statement.
The syntax you construct in these dialog boxes is added to the statement syntax in the SQL Editor window.
Editing a Multi-Row SELECT Statement
If you make changes to a multi-row SELECT, statement, such as rearranging the column order, and you have already linked variables to that statement, you must re-open the Link Variables dialog box and select the OK push button to confirm the changes.
For complete information about linking variables to SQL statements, see Linking Variables to SQL Statements.