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 WaltZ400645 pts.
If you live outside the United States, by submitting your email address you consent to having your personal data transferred to and processed in the United States.
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.
If it is a table or view or index, using DSPFD will show the SQL that was used in creating the object.
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