Tip

Save and rerun SQL statements

You Can View User Feedback To This Tip

If you use STRSQL to develop and run SQL statements, you can save all SQL commands that you ran in a source file, and run them again. Press F13 in the interactive SQL session, option 4 allows you to save the session to a file.

You can reapply the SQL statements with the RUNSQLSTM command. You must have one (1) statement per member to run this command, so some editing of the original saved session is imminent.

Alternately, save the session as a REXX source member, add some REXX statements (see sample code), and use STRREXPRC to execute.

 		
/* Example of running multiple SQL statements from a REXX script */

/* The "ADDRESS EXECSQL" line signals that these are SQL statements and not AS400 commands */
/* All SQL statements start with "EXECSQL"  */
/* Use comma to indicate multiple line statements */

   ADDRESS  EXECSQL

'EXECSQL delete from cmf where cfcset=88 '
                                                                           
'EXECSQL ',
'INSERT INTO V604MMF/CMF SELECT CFID, CFPROD, CFFAC, 88 , CFCBKT,  ',      
'CFTLVL, CFPLVL FROM cmf WHERE cfcset=02'                                  
                                                                           
'EXECSQL ',
'CREATE TABLE QTEMP/QCPYDLMHDR (QLINE CHAR (32766) NOT NULL WITH '  ,      
'DEFAULT) '                                                                
                                                                           
'EXECSQL ',
'DROP TABLE QTEMP/QCPYDLMHDR CASCADE'                                      
                                                                           
'EXECSQL ',
'INSERT INTO V604MMF/QTR (TRID, TRLOT, TRPROD, TRMFGR, TRQTY,      ',      
'TRCNTR, TRRDTE, TRSTAT, TRTIME, TRFAC, TRSHOP) SELECT ''TR'', LLOT,   ',  
'LPROD, LNMFGR, LRCPT+ LADJT- LISS, LNCNTR, LRDT, LMRB, LNLRTM, ''F3''  ', 
', LMSC FROM ilnl01 WHERE lprod=''XYZ0007'' ' 
                                              
'EXECSQL ',
'UPDATE MEDBPCSF/ITHC SET TCID = ''TH'' '     
                                              
'EXECSQL ',
'DELETE FROM FSO WHERE srdte < 19990101 ' 

USER FEEDBACK TO THIS TIP

  • Shalom wrote: You must have one (1) statement per member to run this command, so some editing of the original saved session is required. This is incorrect. Multiple SQL statements can be run in a member just end each statement with a ";". Now you really have the power. &#151;David R. Hoodenpyle


This was first published in May 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.