Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Posts
    12

    Unanswered: SQL in Unix Script Help Needed

    Hi all,

    I am running in AIX 4 using DB2 Connect DB2 SDK 7.2.5. I am writing a script that connects to a UDB running on the mainframe. Here is a snippet of the code:

    for APPSERV in TESTDB
    do

    ( db2 <<-END_DB2
    connect to ${APPSERV} user userid using password
    DB2 UPDATE ${APPSERV}.PSPRCSRQST SET RUNSTATUS = '1',PRCSRTNCD = 0,CONTINUEJOB = 0,ENDDTTM = CURRENT TIMESTAMP,LASTUPDDTTM = CURRENT TIMESTAMP WHERE PRCSINSTANC
    E = 7431

    END_DB2


    The above SQL runs correctly in db2 interactive mode, however, it fails with the following error when I run it via the script:

    DB20000I The SQL command completed successfully.
    db2 => db2 => DB21034E The command was processed as an SQL statement because it
    was not a
    valid Command Line Processor command. During SQL processing it returned:
    SQL0199N The use of the reserved word "SET" following "" is not valid.
    Expected tokens may include: "IS <HEXSTRING> <CHARSTRING> <GRAPHSTRING> ".
    SQLSTATE=42601


    Any ideas?

    Thanks!
    Last edited by everpro; 05-26-04 at 13:19. Reason: forgot one word

  2. #2
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    What's that with the 'DB2 UPDATE...'? At that point you're already in the CLP; shouldn't you just use 'UPDATE...'?

  3. #3
    Join Date
    May 2004
    Posts
    12

    You are correct, that should not be in there.... r/o

    I did not have it originally but then added it after doing some research/troubleshooting..... anyway I still get the failure without it in the script.

  4. #4
    Join Date
    Jun 2003
    Location
    Toronto, Canada
    Posts
    5,516
    Provided Answers: 1
    Try invoking db2 with the "-v" flag: it'll show the the exact statement it is trying to execute. You may be able to see the reason for the error.

  5. #5
    Join Date
    Jun 2002
    Location
    UK
    Posts
    525
    Try this...

    Code:
    for APPSERV in TESTDB
    do
      ( 
          db2 -vt <<- END_DB2
    
          connect to ${APPSERV} user userid using password
          ;
    
          UPDATE ${APPSERV}.PSPRCSRQST 
          SET RUNSTATUS = '1'
          ,     PRCSRTNCD = 0
          ,     CONTINUEJOB = 0
          ,     ENDDTTM = CURRENT TIMESTAMP
          ,     LASTUPDDTTM = CURRENT TIMESTAMP 
          WHERE PRCSINSTANCE = 7431 
          ;
    
    END_DB2
    
      )
    
    done

  6. #6
    Join Date
    May 2004
    Posts
    12

    Thanks, got it working!

    Many thanks!!! It is working, now on to the next problem!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •