MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » August 2005

RE: Can CL write to a disk file



fixed

Rob:

There are a couple ways to coerce CL into "writing" to disk -- I won't count QM 
query since you're using it.

However, try making these changes:

Assuming four CHAR columns, for your QM SQL --

 INSERT INTO OUTQFIX
 VALUES(&q&OUTQFIX_OUTQ&q, &q&OUTQFIX_AUTHLIST&q, &q&OUTQFIX_CHANGED&q,
        &q&OUTQFIX_MSGID&q)

And to your STRQMQRY command:

  STRQMQRY QMQRY(OUTQFIX) +
        SETVAR((OUTQFIX_OUTQ &OUTQFIX_OUTQ) +
               (OUTQFIX_AUTHLIST &OUTQFIX_AUTHLIST) +
               (OUTQFIX_CHANGED &OUTQFIX_CHANGED) +
               (OUTQFIX_MSGID &OUTQFIX_MSGID) +
                ('q' '''') +
               )

That shifts the burden for quoting mostly to the SQL statement. The CL merely 
needs to pass a single quote into the &q substitution variable that's used 
wherever needed. You can vary that in numerous ways, but you probably can get 
the idea. Too bad it isn't just a list option for the SETVAR() parm.

Consider this possibility if you have QShell installed:

  call QZDFMDB2  ( +
 'INSERT INTO OUTQFIX VALUES(''' *cat +
    &OUTQFIX_OUTQ *cat ''',''' *cat +
    &OUTQFIX_AUTHLIST *cat ''',''' *cat +
    &OUTQFIX_CHANGED *cat ''',''' *cat +
    &OUTQFIX_MSGID *cat '')' +
                  )

And also note that QLGSORT will take an input buffer as a parm and output to a 
sorted outfile. The input buffer in your case would simply be a CL variable 
with this value:

 [ &OUTQFIX_OUTQ *cat &OUTQFIX_AUTHLIST *cat &OUTQFIX_CHANGED *cat 
&OUTQFIX_MSGID ]

The buffer can be defined for one record at a time or multiple records.

Tom Liotta

midrange-l-request@xxxxxxxxxxxx wrote:

>   6. Can CL write to a disk file (rob@xxxxxxxxx)
>
>Is there a command like SNDF that will work to a disk file?  V5R3.
>
>Trying  workarounds like
>  CHGVAR VAR(&OUTQFIX_OUTQ) VALUE('A')
>  CHGVAR VAR(&OUTQFIX_AUTHLIST) VALUE('A')
>  CHGVAR VAR(&OUTQFIX_CHANGED) VALUE('A')
>  CHGVAR VAR(&OUTQFIX_MSGID) VALUE('A')
>  STRQMQRY QMQRY(OUTQFIX) +
>         SETVAR((OUTQFIX_OUTQ &OUTQFIX_OUTQ) +
>                (OUTQFIX_AUTHLIST &OUTQFIX_AUTHLIST) +
>                (OUTQFIX_CHANGED &OUTQFIX_CHANGED) +
>                (OUTQFIX_MSGID &OUTQFIX_MSGID)) 
>Which executes
>INSERT INTO OUTQFIX 
>VALUES(&OUTQFIX_OUTQ, &OUTQFIX_AUTHLIST, &OUTQFIX_CHANGED,
>       &OUTQFIX_MSGID) 
>But I get stupid messages like:
>CALL ROB/TESTFIX 
>   215 - STRQMQRY QMQRY(OUTQFIX) SETVAR((OUTQFIX_OUTQ 'A') 
>  (OUTQFIX_AUTHLIST 'A') (OUTQFIX_CHANGED 'A') (OUTQFIX_MSGID 'A'))
>Column A not in specified tables. 
>RUN QUERY command failed with SQLCODE -206. 
>
>And I'm just plain disgusted playing the apostrophe game.






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact