/* RUNSQL -- The CPP for the QMQRY-based RUNSQL example */ /* Note that the SQL parm may end in a quote. We'll strip it later. */ parse arg 'SQL('sqlstring') OUTPUT(' arg 'OUTPUT('output')' arg 'OUTFILE('outf_lib'/'outf')' arg 'MEMBER('member_list')' signal on error name command_error signal on failure name command_error signal on syntax name syntax_error if member_list = '' then member_opt = '*REPLACE' else member_opt = member_list /* Strip aposts because CL would not have them... */ /* */ /* The incoming SQL parm may contain embedded */ /* quotes and apostrophes. These can make a */ /* mess of things because the CL prompter will */ /* automatically double them. When the string */ /* eventually gets passed to SQL, they need to */ /* be "de-doubled". We use REXX INTERPRET to */ /* do this for us. Note that this isn't */ /* relevant in CL. */ /* Eliminate outer aposts and any inner doubled quotes and/or */ /* aposts by interpreting the value... */ sqlstring = 'sql = 'sqlstring /* This executes "sql = sqlstring" */ interpret sqlstring /* Break the input string down into substrings 55 chars or less... */ f01=substr(sql,1,55) f02=substr(sql,56,55) f03=substr(sql,111,55) f04=substr(sql,166,55) f05=substr(sql,221,55) f06=substr(sql,276,55) f07=substr(sql,331,55) f08=substr(sql,386,55) f09=substr(sql,441,55) f10=substr(sql,496,55) f11=substr(sql,551,55) f12=substr(sql,606,55) f13=substr(sql,661,55) f14=substr(sql,716,55) f15=substr(sql,771,55) f16=substr(sql,826,55) f17=substr(sql,881,55) f18=substr(sql,936,55) f19=substr(sql,990,9) /* Pass the substrings into STRQMQRY... */ select when output = '*' then outopts = '' when output = '*OUTFILE' then outopts = 'OUTFILE(&outf_lib/&outf) ', 'OUTMBR(*FIRST &member_opt) ', when output = '*PRINT' then outopts = '' end 'STRQMQRY QMQRY(*LIBL/CLSQL) OUTPUT('output') ', outopts, 'SETVAR((F1 &f01) (F2 &f02) (F3 &f03) (F4 &f04) ', '(F5 &f05) (F6 &f06) (F7 &f07) (F8 &f08) (F9 &f09) ', '(F0 &f10) (FA &f11) (FB &f12) (FC &f13) (FD &f14) ', '(FE &f15) (FF &f16) (FG &f17) (FH &f18) (FI &f19))' end_program: exit /* ---------------------------------------------------------------- */ command_error: parse source system start srcmbr srcf srcf_lib say 'Unexpected error at line 'sigl' of REXX program ', srcmbr' in 'srcf_lib'/'srcf'. The exception ID is 'rc'.' exit(right(rc,4)) syntax_error: trace off parse source system start srcmbr srcf srcf_lib say 'Syntax error at line 'sigl' of REXX program ', srcmbr' in 'srcf_lib'/'srcf'. The error code is 'rc'.', ' The description is :' say errortext(rc) exit(rc)