Sql statement

Tags:
RPG
After running a query interactively, how can I retrieve the SQL statement of that query defenition.

Answer Wiki

Thanks. We'll let you know when a new response is added.

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.

Discuss This Question: 2  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TimRac
    If it is a table or view or index, using DSPFD will show the SQL that was used in creating the object.
    25 pointsBadges:
    report
  • TomLiotta
    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
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following