View previous topic :: View next topic
|
Author |
Message |
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
Hi all,
I would like to update a DB2 table row using a query similar to this..
Code: |
UPDATE <TABLE>
SET <Column-1> = <Host Variable-1>
WHERE <Column-2> = <Host Variable-2>
|
How do I do that in a REXX Program?
Thanks in advance |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
IBM website - redbooks
Find and read
Squeezing the most out of dynamic SQl with DB2 for z/OS and OS/390
Has a whole chapter on SQL with REXX |
|
Back to top |
|
|
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
Thank you.. That would be of great help.
Would be appreciated if I get a piece of code to go ahead faster . |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Quote: |
Would be appreciated if I get a piece of code to go ahead faster |
Well, once the funds have cleared, 750 per day or part there of - code will be delivered.
DO NOT ask for code without at least showing what you have coded yourself and what the errors are. Asking for code like that is downright lazy !!!!! |
|
Back to top |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
Would be appreciated if I get a piece of code to go ahead faster |
This will get you started:
Code: |
/* rexx */
/* add your logic here */
|
|
|
Back to top |
|
|
Vishwamurthy
New User
Joined: 11 Mar 2008 Posts: 57 Location: India
|
|
|
|
Thanks expat!
The Redbook DB2 for z/OS and OS/390 : Squeezing the Most Out of Dynamic SQL has it all
My
Code: |
/* REXX */
ADDRESS TSO "SUBCOM DSNREXX"
SQLSTMT = "UPDATE AGENT SET ADDRESS = ? WHERE AGENTID = ?"
SAY 'ENTER YOUR ID'
PULL AGENTIDA
SAY 'ENTER YOUR NEW ADDRESS'
PULL ADDA
ADDRESS DSNREXX
"CONNECT DSN1"
"EXECSQL DECLARE C1 CURSOR FOR S1"
"EXECSQL PREPARE S1 FROM :SQLSTMT"
"EXECSQL EXECUTE S1 USING :ADDA, :AGENTIDA"
IF SQLCODE = 0 THEN
SAY 'UPDATE SUCCESSFUL'
ELSE
DO
SAY 'UPDATE OPERATION FAILED. ERROR DETAILS ARE'
SAY 'SQLCODE' SQLCODE 'AND SQLSTATE' SQLSTATE
END
"DISCONNECT DSN1"
|
I am sorry for asking for the code before trying anything..
I am now happy I know Dynamic SQL (I have read that 290 page book and only then started coding). |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Great to see that you have done it.
Don't forget the SQLCA parts which will get any error messages and codes. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
Quote: |
I have read that 290 page book and only then started coding |
Impressive. I usually only read the page that I need. Knowing which manual to use is 99 percent of the battle. When I need more, I read more of it. |
|
Back to top |
|
|
|