0 pts.
 Sql statement
RPG
After running a query interactively, how can I retrieve the SQL statement of that query defenition.

Software/Hardware used:
ASKED: April 20, 2006  9:35 AM
UPDATED: November 19, 2010  7:15 AM

Answer Wiki:
If you are talking about an iSeries query (object type *QRYDFN) use the following command to get the SQL statement. RTVQMQRY QMQRY(queryname)ALWQRYDFN(*YES) On the command also specify the source file and member you want this copied into.
Last Wiki Answer Submitted:  April 20, 2006  12:35 pm  by  WaltZ400   645 pts.
All Answer Wiki Contributors:  WaltZ400   645 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

If it is a table or view or index, using DSPFD will show the SQL that was used in creating the object.

 25 pts.

 

If you’re talking about interactive queries through STRSQL, you can save the session into a source file member when you exit by taking option 4, ‘Save session in source file’. If you take option 2, ‘Exit without saving session’, the session history is discarded.

Option 1, ‘Save and exit session’, keeps the session history in an internal object related to the user profile. If you run STRSQL from a second workstation session at the same time, a second session history is started. Both histories become linked to the device names. To reconnect to one of the histories, you should sign on to the same device. Signing on to a different session can make it look like history has disappeared.

As long as history has been saved, you can re-enter STRSQL and recall past queries by pressing <F9>. You can page backwards until you find a query (statement) that you want, put the cursor on the statement and press <F9>. The statement will be brought forward to the SQL command line.

Retrieving directly from STRSQL history or indirectly from a session saved in a source member is a way to get back the SQL used in an interactive query. If the session was discarded, it’s gone.

Tom

 107,995 pts.