update query

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
rekha
Member
Posts: 4
Joined: Wed Aug 27, 2008 12:00 pm
Location: coimbatore

update query

Post by rekha » Wed Dec 03, 2008 6:17 pm

HI,
i m running a query and it is an update query..i want it to write it to a ps file and count the number of rows updated.so my question is how to write the updated fields alone to the ps...and how the cursor to be used..because using cursors oly we can write the result fetched to a ps file..?????????and one more thing cursor are supposed to be declared oly for select stmts or could it be used for update also?

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

COBOL DB2 FINAL TABLE

Post by Natarajan » Wed Dec 03, 2008 6:32 pm

Hi Rekha,

welcome to mainframegurukul.com.

I am giving answer as per my understanding of your question.
i assume, you want the row that got updated by the query and want to write it to PS.

Here is the solution. In db2 8, we can select row that got updated currently.

Ex.

Code: Select all

SELECT    SSN, ADDRESS , Y, Z FROM FINAL TABLE 
( UPDATE   TABLE1
   SET     ADDRESS :=   :WS-ADDRESS
   WHERE  SSN :=  10290 ) 
Above example will give the details about the record currently updated.

Note : FINAL TABLE is a key word.

regarding your question on cursors - We can use cursor for updates also, for that,
we need to use FOR UPDATE OF option in CURSOR definition.


if my answer not cleared your doubt, let me know.
Natarajan
Chennai

rekha
Member
Posts: 4
Joined: Wed Aug 27, 2008 12:00 pm
Location: coimbatore

Post by rekha » Wed Dec 03, 2008 7:01 pm

Thank you! but i want to update the same table..is that also possible and thru this if i fetch it the updated rows alone ll be fetched or....wat anyways i m going to try it out.....Thank you so much

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Thu Dec 04, 2008 1:16 pm

let me know after testing, if you still have the issues.
Natarajan
Chennai

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others