CL Program: Assing select to the variable

Tags:
AS/400
CL Program
Hi,
I have some trouble with my CL Program. Please help me.
I have a table like:
System name         User name              Job name
tstname1c             TOMCATTOMT       TOMCATTOM1
.......................             .......................                 .......................
tstname1a             BOBCATBOBB        BOBCATBOB2
.......................             .......................                 .......................
.......................             .......................                 .......................
.......................             .......................                 .......................
tstname1d             LOLCATLOLL          LOLCATLOL3
.......................             .......................                 .......................
.......................             .......................                 .......................
.......................             .......................                 .......................
 
In that table (name TSTTABLE) you can find 250+ records.
CL VARIABLE               TYPE     LENGTH     PRECISION     TEXT        
&AJSYS                   *CHAR       8                     System name 
&AJUSR                   *CHAR      10                     User name
&AJJOB                   *CHAR      10                     Job name
I need to assign USER NAME for &USRNAM variable where  Job Name like TOMCATTOM1
 
i suppose that i can do it with SQL Request but that is deadlock for me:
 
CHGVAR     VAR(&SQL_T) VALUE( 'select  AJUSR from   TSTTABLE where   AJJOB like('TOMCATTOM1'))
This request will show a field named TOMCATTOMT. I need to assign that to the &USRNAM variable?
 
How can I do it?
0

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

Discuss This Question: 7  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.
  • philpl1jb

    That would depend on what you mean by the word Assign.

    Do you mean update the file with that new value in the field?

    Not sure what you mean by "deadlock", are you allowed to use SQL but don't know how to, or are you prohibited for some reason from using SQL?

    54,090 pointsBadges:
    report
  • Motorbreath
    that is not easy for me try to discussing on english :) so, i'm try to do it. Thx for help.

    ''That would depend on what you mean by the word Assign.''
    assign is '' := ''
    DCL VAR (&A) TYPE(*INT) VALUE(1)
    DCL VAR (&B) TYPE(*INT) 
    CHGVAR VAR(&B) VALUE(&A)

    That is what i mean when use 'assign'
    I can use all what i want. AS400 V7R1M0 

    How can i assign result of SQL Select to the variable?
    Do you understad what i mean?

    Best Regards...

    70 pointsBadges:
    report
  • Motorbreath
    Or if u know how..i can use another way without SQL Request
    70 pointsBadges:
    report
  • philpl1jb
    It doesn't look like the Sql implementation in CL will allow
    54,090 pointsBadges:
    report
  • philpl1jb

    It doesn't look like the Sql implementation in CL will allow host values.

    I would just code this with a

    DCLF TSTTABLE

    Loop:

       Rcvf

       MONMSG     MSGID(CPF8064) EXEC(GOTO CMDLBL(NotFound))        

     If (&TSTTABLE *EQ 'TOMCATTOM1') goto Continue

    Go to Loop

      

    54,090 pointsBadges:
    report
  • philpl1jb

    :Continue

    ChgVar  &USRNAM &AJUSR

    54,090 pointsBadges:
    report
  • Motorbreath
    Philip!!! Thx a lot!!!!
    70 pointsBadges:
    report

Forgot Password

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

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

Thanks! We'll email you when relevant content is added and updated.

Following

Share this item with your network: