Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Query manager variable from CL

184 views
Skip to first unread message

tomasz

unread,
Feb 6, 2007, 9:32:08 AM2/6/07
to
Hi.
I have another QM related problem.

I would like my CL to run sql procedure.
Please see below it's a part of my code:

PGM PARM(&RRN)
DCL VAR(&RRN) TYPE(*CHAR) LEN(10)
DCL VAR(&RRN12) TYPE(*CHAR) LEN(12)
CHGVAR VAR(&RRN12) VALUE('''' *TCAT &RRN *TCAT '''')
STRQMQRY QMQRY(CWTOSTLIB/CWJRN) SETVAR(RRN &RRN12)
MONMSG QWM2701
ENDPGM

query looks like this:

SELECT * FROM qtemp/dspjrn WHERE JOCTRR = &RRN

variable from CL is *CHAR, it needs to be *char, otherwise SETVAR won't
work. unfortunatelly field JOCTRR is *DEC.

Ehen I start my program with some numeric parameter (for example CALL
TEST '34343') I get a Query error message '34343' is not a valid query
manager variable.

I think it's a *CHAR/*DEC field definitin.
Am I right? Can I somehow pass *dec variable to sql statement using
STRQMQRY command?

Regards,
Tomasz

Dr.UgoGagliardelli

unread,
Feb 6, 2007, 9:39:01 AM2/6/07
to
il 06/02/2007 15.32, Scrive tomasz 38684688:

> Hi.
> I have another QM related problem.
>
> I would like my CL to run sql procedure.
> Please see below it's a part of my code:
>
> PGM PARM(&RRN)
> DCL VAR(&RRN) TYPE(*CHAR) LEN(10)
> DCL VAR(&RRN12) TYPE(*CHAR) LEN(12)
> CHGVAR VAR(&RRN12) VALUE('''' *TCAT &RRN *TCAT '''')
> STRQMQRY QMQRY(CWTOSTLIB/CWJRN) SETVAR(RRN &RRN12)
> MONMSG QWM2701
> ENDPGM
>
> query looks like this:
>
> SELECT * FROM qtemp/dspjrn WHERE JOCTRR = &RRN

[...]
The statement:


CHGVAR VAR(&RRN12) VALUE('''' *TCAT &RRN *TCAT '''')

make the value in quotes, so the select statement evaluete the where
condition as a string compare, you should change the statement without
quotes, like this:
CHGVAR VAR(&RRN12) VALUE(&RRN)

--
Dr.Ugo Gagliardelli,Modena,ItalyCertifiedUindoscrasherAñejoAlcoolInside
Spaccamaroni andate a cagare/Spammers not welcome/Spammers vão à merda
Spamers iros a la mierda/Spamers allez vous faire foutre/Spammers loop
schijten/Spammers macht Euch vom Acker/Spamerzy wypierdalac'

Saml

unread,
Feb 6, 2007, 7:49:58 PM2/6/07
to
Remember that the variable you subsititue in the SETVAR command (&RRN in
this case) is always character. If it is supposed to be character in the
SQL then it needs ticks around it. If it is numeric in the SQL then it
doesn't need the ticks.

Always consider the SQL string that you are trying to create--should it have
ticks after you subsititue or not?

Since JOCTRR is numeric, the SQL string you are trying to create is
something like
SELECT * FROM qtemp/dspjrn WHERE JOCTRR = 1234567

Therefore &RRN value shouldn't have ticks.

Sam

"tomasz" <t...@nospam.com> wrote in message
news:eqa3o8$s92$1...@nemesis.news.tpi.pl...

tomasz

unread,
Feb 7, 2007, 3:22:52 AM2/7/07
to
I've made a mistake yesterday.
I used DSPFFD command against my DSPJRN table and I've get information
like this:


Field Level Information
Data Field Buffer Buffer Field Column
Field Type Length Length Position Usage Heading

JOCTRR ZONED 10 0 10 97 Both COUNT/

RRN

Field text . . . . . . . . . . . . . . . : Count or relative
record number changed

What does ZONED means? I belive it's important in that case.

I've modified my CL like you suggested and it still doesn't work. I
belive that what DSPFFD shows is important in that issue.

Table DSPJRN is an output for DSPJRN command (QADSPJRN format).


Regrds,
Tomasz


Saml napisał(a):

Dr.UgoGagliardelli

unread,
Feb 7, 2007, 3:40:27 AM2/7/07
to
il 07/02/2007 9.22, Scrive tomasz 40699704:

> I've made a mistake yesterday.
> I used DSPFFD command against my DSPJRN table and I've get information
> like this:
>
>
> Field Level Information
> Data Field Buffer Buffer Field Column
> Field Type Length Length Position Usage Heading
>
> JOCTRR ZONED 10 0 10 97 Both COUNT/
> RRN
> Field text . . . . . . . . . . . . . . . : Count or relative record
> number changed
>
> What does ZONED means? I belive it's important in that case.
>
> I've modified my CL like you suggested and it still doesn't work. I
> belive that what DSPFFD shows is important in that issue.
>
> Table DSPJRN is an output for DSPJRN command (QADSPJRN format).
ZONED means that the field is numeric so a cl program that declare the
file QADSPJRN, automatically define a variable *DEC (10 0), to pass this
variable to qmquery you shoul convert to a *char variable e.g.:

dclvar &rrn *char 10

...
chgvar &rrn &JOCTRR

tomasz

unread,
Feb 7, 2007, 4:18:15 AM2/7/07
to
Hi.
My mistake. Thank you.
It's fine now.

Tomasz

Dr.UgoGagliardelli napisał(a):

0 new messages