If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > SQL in Unix Script Help Needed

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-26-04, 12:18
everpro everpro is offline
Registered User
 
Join Date: May 2004
Posts: 12
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 12:19. Reason: forgot one word
Reply With Quote
  #2 (permalink)  
Old 05-26-04, 14:09
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
What's that with the 'DB2 UPDATE...'? At that point you're already in the CLP; shouldn't you just use 'UPDATE...'?
Reply With Quote
  #3 (permalink)  
Old 05-27-04, 11:22
everpro everpro is offline
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old 05-27-04, 14:10
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
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.
Reply With Quote
  #5 (permalink)  
Old 05-27-04, 18:12
Damian Ibbotson Damian Ibbotson is offline
Padawan
 
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
Reply With Quote
  #6 (permalink)  
Old 06-01-04, 15:07
everpro everpro is offline
Registered User
 
Join Date: May 2004
Posts: 12
Thanks, got it working!

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

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On