Get started Bring yourself up to speed with our introductory content.

SQL statement history storage

Hitting the wrong button in iSeries can cause a serious headache. If you have exited an STRSQL session without saving and want to retrieve your lost information, you may be out of luck. But Scott Ingvaldson explains where SQL statement history is stored, and how it can be retrieved.

I was using the standard STRSQL command and exited after use. When I exited I chose option 2=Exit without saving...

session, instead of option 1=Save and exit session. Now I have lost all my cumulative SQL history. Do you know where this data was kept? I may be able to restore it from my last backup. I have been unable to locate where the SQL statement history is kept.

Interactive SQL statement history is kept in an object named ISQLST-usrprf-devicename in the library QRECOVERY.

You can display the statement history with this command:

Unfortunately, Qrecovery does not get saved with the standard save commands. Unless you have explicitly saved objects from Qrecovery, I don't think you'll have anything to restore. If you had lost your SQL statement history due to changing your device name you might be able to retrieve it with the above command.

A more permanent way to save your statement history when exiting SQL is to use option 4=Save session in source file.

Dig Deeper on iSeries SQL commands and statements