Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Issuing UPDATE in COBOL-DB2 program without CURSOR

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
bosalting

New User


Joined: 02 Jun 2007
Posts: 4
Location: Philippines

PostPosted: Mon Sep 10, 2007 11:04 am    Post subject: Issuing UPDATE in COBOL-DB2 program without CURSOR
Reply with quote

Hi everyone,

Im wondering, there's an impedance mismatch between set-level processing of DB2 and record-level processing of COBOL.. That's why we use CURSORs right? Would it be possible to UPDATE a table in one blow, affecting several rows in a program. If its possible, is it advisable resource-wise? A related reading material would be most appreciated..
Back to top
View user's profile Send private message

stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Mon Sep 10, 2007 5:30 pm    Post subject:
Reply with quote

You don't need cursors to do updates to a table. The only time a cursor is needed is when reading multiple rows from a table.
Back to top
View user's profile Send private message
bosalting

New User


Joined: 02 Jun 2007
Posts: 4
Location: Philippines

PostPosted: Thu Sep 13, 2007 12:58 pm    Post subject:
Reply with quote

Steve,

Yes you do need a CURSOR if you want to update a table with multiple rows. You UPDATE it one at a time. Thats why in the CURSOR declaration for an update, you use keywords FOR UPDATE OF...
Back to top
View user's profile Send private message
stodolas

Active Member


Joined: 13 Jun 2007
Posts: 632
Location: Wisconsin

PostPosted: Thu Sep 13, 2007 6:31 pm    Post subject:
Reply with quote

But, if you do this

Code:

EXEC SQL
    UPDATE TABLE
    SET COLUMN1 = SomeVal
END-EXEC


I have updated multiple rows without using a cursor....
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Sep 13, 2007 7:12 pm    Post subject:
Reply with quote

Hello,

Quote:
Yes you do need a CURSOR if you want to update a table with multiple rows. You UPDATE it one at a time
No, you do not have to use a cursor to update multiple rows. You can update multiple (selected) rows in a table by specifying a WHERE and you can update every row in a table if you do not specify a WHERE.

You update one row at a time when you are updating a row that was read by a cursor.
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 -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Testing rerad cursor for status with ... John F Dutcher DB2 8 Fri May 19, 2017 9:35 pm
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
This topic is locked: you cannot edit posts or make replies. Merge two files and update Trailer re... Yashashri JCL & VSAM 1 Thu May 04, 2017 12:54 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us