Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Update a DB2 Table Row

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX
View previous topic :: :: View next topic  
Author Message
Vishwamurthy

New User


Joined: 11 Mar 2008
Posts: 57
Location: India

PostPosted: Wed Jun 03, 2009 5:12 pm    Post subject: Update a DB2 Table Row
Reply with quote

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
View user's profile Send private message

expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 03, 2009 5:31 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Vishwamurthy

New User


Joined: 11 Mar 2008
Posts: 57
Location: India

PostPosted: Wed Jun 03, 2009 5:35 pm    Post subject:
Reply with quote

Thank you.. That would be of great help.

Would be appreciated if I get a piece of code to go ahead faster icon_smile.gif.
Back to top
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Wed Jun 03, 2009 5:37 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6968
Location: porcelain throne

PostPosted: Wed Jun 03, 2009 6:10 pm    Post subject:
Reply with quote

DB2 for z/OS and OS/390 : Squeezing the Most Out of Dynamic SQL

DB2 for z/OS Stored Procedures: Through the CALL and Beyond

DB2 9 for z/OS Stored Procedures: Through the CALL and Beyond

All have chapters on REXX, with examples that you can cut&paste "to go ahead faster ".
Back to top
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2086
Location: Silicon Valley

PostPosted: Wed Jun 03, 2009 7:49 pm    Post subject: Reply to: Update a DB2 Table Row
Reply with quote

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
View user's profile Send private message
Vishwamurthy

New User


Joined: 11 Mar 2008
Posts: 57
Location: India

PostPosted: Thu Jun 04, 2009 7:45 pm    Post subject:
Reply with quote

Thanks expat!
The Redbook DB2 for z/OS and OS/390 : Squeezing the Most Out of Dynamic SQL has it all icon_smile.gif

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
View user's profile Send private message
expat

Global Moderator


Joined: 14 Mar 2007
Posts: 8593
Location: Back in jolly old England

PostPosted: Thu Jun 04, 2009 8:01 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Pedro

Senior Member


Joined: 01 Sep 2006
Posts: 2086
Location: Silicon Valley

PostPosted: Thu Jun 04, 2009 10:46 pm    Post subject: Reply to: Update a DB2 Table Row
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> CLIST & REXX All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm
No new posts how to see when the last read access ... Mike 1304 DB2 1 Tue Sep 12, 2017 7:52 pm
No new posts PC (UTF-8) -> z/OS (EBCDIC) -> ... prino All Other Mainframe Topics 4 Fri Sep 01, 2017 1:47 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us