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


Retrieving and Correcting SQL Lines

You can use the RETRIEVE function to correct a statement already in the command line buffer. RETRIEVE moves the previously-typed line into the input area. The following example shows how to retrieve and correct a line in the output area. Type the following and press ENTER:

   select actnum,actkwd,actdesc -

The line is moved to the output area.

Now type:

   from activity

Press ENTER.

An error message is issued indicating that the column ACTNUM was not found. (ACTNO is the correct name.)

To retrieve the last input line entered, press the PF12 key to invoke the RETRIEVE function. The following line is now displayed in the input area with the cursor positioned at the end of the line:

   from activity

Press the PF12 key again to retrieve the previous input line. The input area now contains:

   select actnum,actkwd,actdesc -

with the cursor positioned at the end of the line. You can now correct the error as you would any other error in the input area by backspacing and typing the correct characters.

After you have corrected the line in the input area, press ENTER.
DB2 Server for VSE

The corrected line is now displayed in the output area, and CONTINUE COMMAND has appeared in the status area to confirm that you are to continue entering the statement.

DB2 Server for VM

The corrected line is now displayed in the output area, VM READ has appeared in the status area, and message ARI7068I has appeared in the output area to confirm that you are to continue typing the statement.

Continue the statement by using either of the following two methods:

The result is the same using either method: the SELECT statement is reissued.
Note:The command buffer holds a variable number of statements, depending on their length. If your statements are short, the buffer can hold more of them. As you press PF12 repeatedly, the system retrieves statements from the buffer starting with the most recent, and continues until it retrieves the oldest statement. Then it starts over and returns the most recent statement.
DB2 Server for VM

The RETRIEVE facility functions differently in wait mode compared to display mode. In display mode, the system can retrieve any information typed during the ISQL session that is still contained in the command buffer. In wait mode (VM READ shows in the status area of the display), the system can retrieve information typed in wait mode or from a time prior to starting ISQL.

Incorrect information typed from wait mode can be retrieved immediately, and corrected as illustrated in the previous example. Incorrect information typed from display mode forces display mode to end, and returns you to wait mode. Pressing PF12 does not retrieve the incorrect information in this case, because you typed it from display mode. The following examples illustrate the RETRIEVE-function differences between wait and display mode.

Ensure that you are in wait mode. If you do not see VM READ in the lower-right corner of your display, press PF3. Now, type the following (with activity spelled incorrectly):

   select * from abtivity

An error message is issued indicating that ABTIVITY cannot be found. Press PF12. The incorrect select * from abtivity statement appears in your input area, where you can correct it.

Erroneous lines typed from display mode cannot be immediately retrieved with RETRIEVE key PF12. To illustrate, type the following correct statement from wait mode.

   select * from activity

The ACTIVITY table is displayed, and the message disappears from the status area to indicate that you are in display mode.

Do not press PF3 to end the display. Instead, type the following incorrect statement from display mode:

   select * from supply

The SUPPLY table is not found; VM READ reappears in the lower-right corner of your display to indicate that you are back in wait mode.

Now, press PF12. select * from activity appears in the input area. It is not the last statement you typed, but is the last one you typed from wait mode. The line in error that was entered from display mode cannot be retrieved from wait mode. It has been saved, however, and can be retrieved when you return to display mode. To illustrate this, enter the following correct query, which returns you to display mode:

   select actno from activity

Now, from display mode, press PF12. The last line typed, select actno from activity, appears in the input area.

Press PF12 again. This time the line in error, select * from supply, does appear in the input area.

DB2 Server for VM

All lines typed during an ISQL session can be retrieved from within display mode (up to the maximum number of lines the buffer can hold), including lines entered from display mode and wait mode. Only those lines entered from wait mode can be retrieved from wait mode. Since ISQL commands other than display commands, SQL statements other than SELECT, and incorrect SELECT statements entered from display mode return you to wait mode, you cannot immediately retrieve this type of statement or command. Pressing PF3 after you have finished each query ensures that you enter each statement or command from wait mode and can immediately retrieve and change the information.


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