-
Free Program Runsqlstm In Cl Program Examples카테고리 없음 2020. 2. 26. 10:55
Better yet, you can pass parameters to SEQUEL's RUNSCRIPT command.SEQUEL has recently added CL style coding capability, including IF-THEN-ELSElogic.Paul NelsonOffice 512-392-2577Cell 708-670-6978nelsonp@xxxxxxxxxxxxx-Original Message-From: midrange-l-bounces@xxxxxxxxxxxxmailto:midrange-l-bounces@xxxxxxxxxxxx On Behalf Of Vern HambergSent: Tuesday, March 02, 2010 7:26 AMTo: Midrange Systems Technical DiscussionSubject: Re: Calling a SQL script with parameters from CL programDinaYou can't pass parameters to RUNSQLSTM. You CAN pass 'parameters' to aQM query, which I prefer for this kind of thing. It is possible toexecute multiple QM queries using a QM procedure, by the way, butpassing parameters to that is not as easy.Also, you cannot run a SELECT in RUNSQLSTM.Do you have STRSQL on your machine?
Then you also have STRQM (StartQuery Manager). This is a front end to QM (Query Management) queries andforms. A query and form together are almost equivalent to a Query/400query definition.Or you can CRTSRCPF YOURLIB/QQMQRYSRC RCDLEN(91)Yes, 91 - for reasons not known to me.Create a member there and put this statement in it. This containssubstitution variables - similar to merge variables in Query/400.
With Nc Sql
Thevariables are &QT - will be a quote mark - and &DATE - your date.SELECT FLD1,FLD2,FLD3,FLD4FROM MYFILEWHERE FLD1 = &QT&DATE&QTThen use CRTQMQRY to create the QM query, say YOURLIB/YOURQMQRY.To execute the select, do something like this -STRQMQRY YOURLIB/YOURQMQRY SETVAR((QT ') (DATE '20080228'))You can also have an OUTFILE in your STRQMQRY - in RUNSQLSTM you need aCREATE TABLE based on a SELECT, perhaps. Or INSERT INTO with a subselect.Anyhow, create all the QM queries you need. If you create them in STRQM,you will have to get privileges there to do more than SELECT statements.If you do it from source, no limitations. Also, take a look at WRKQMQRY.In your CL, use all the STRQMQRY's you need.
Resolving The ProblemIBM SQL/400 statements can be embedded in many HLL programs, and there is also an occasional need to embed these statements in a CL program. While the IBM DB2 Query Manager and SQL Development Kit for AS/400 57nnST1 (where nn is any number) provides pre-compiler support for embedding SQL in HLL programs, no support is provided for CL programs.There are, however, at least three techniques available to include SQL statements in a CL program:12Put the SQL statement in a source member and use the RUNSQLSTM command to execute it. An SQL script of multiple SQL statements can be created by adding a semicolon after each statement. There are limits, however, on what SQL statements can be run in this fashion, and the command is currently not included in the base operating system and only shipped with the 57nnST1 product.Use the RUNSQL command (new at R610 and R710 with PTFs ).
The RUNSQL CL command allows an SQL statement to be run from within a CL program without needing a source file. The statement can be up to 5000 characters long and not ending in a semicolon. There are limits, however, on what SQL statements can be run using this command. Refer to the following URL for more detials.Further information about the new command can be found in document N1010961, RUNSQL Command or URL:The PTFs which introduce the new command are as follows:R610APAR SE51168 PTF SI46208 and is included in group PTF SF99601 level 25.R710APAR SE51276 PTF SI46219 and is included in group PTF SF99701 level 14.3Put the SQL statement in a source member and use the CRTQMQRY command to create a QMQRY object and then use STRQMQRY to run the query. Only a single SQL statement can be run in this fashion. (Multiple statements can be executed with Query Management Procedures.) One advantage to this approach is that you can pass parameters to the SQL statement.4To allow a short dynamic statement to be run (up to 55 characters in length) users can create their own command.