473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Returning rows after select for update and update current of

Hi,

I'm using stored procedures in DB2 UDB 8.1.2. In this stored, I execute
a select for update command, opening a cursor. Then I update the rows
using fetch and current of. The problem is that I want to return the
rows for my Java application. But if I set the cursor of the select for
WITH RETURN, I get the values, but I cant execute the update. If I dont
use WITH return, I execute the update, but I cant get the result set.
Any ideas.

Thank you

Oct 19 '06 #1
2 7686
<mo*******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
Hi,

I'm using stored procedures in DB2 UDB 8.1.2. In this stored, I execute
a select for update command, opening a cursor. Then I update the rows
using fetch and current of. The problem is that I want to return the
rows for my Java application. But if I set the cursor of the select for
WITH RETURN, I get the values, but I cant execute the update. If I dont
use WITH return, I execute the update, but I cant get the result set.
Any ideas.

Thank you
In a similar situation, I did the following:

I first get a unique timestamp from DB2. Then when I update each row where
current of the cursor (cursor not defined as WITH RETURN), I use the unique
timestamp to update one of the columns (such as CHANGED_TS column defined as
a timestamp).

Then after I close the cursor above, I open another cursor WITH RETURN to
select the rows with the timestamp that I obtained in the beginning and that
was used for each row I updated.

Another option is to define a temporary table and insert the updated rows
into the temp table. Then at the end, open a cursor WITH RETURN with the
results of the temp table.

For my particular situation, the first option tested faster than the temp
table, but that would depend on the number of rows in the table, whether you
have an index on the timestamp column, bufferpool hit ratio, and other
related factors.
Oct 19 '06 #2
Can you place the UPDATE inside the cursor?

DECLARE cur CURSOR WITH RETURN FOR
SELECT * FROM NEW TABLE(UPDATE T SET ....)

Works in DB2 V8.1.4 for LUW and up
Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

IOD Conference
http://www.ibm.com/software/data/ond...ness/conf2006/
Oct 19 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Colin Steadman | last post by:
Part No Description Quantity 45643 Random part 10 45678 Another Random part 7 98944 And another 1 <submit button> ...
9
by: Rowland Hills | last post by:
I have a table which is returning inconsistent results when I query it! In query analyzer: If I do "SELECT * FROM TABLE_NAME" I get no rows returned. If I do "SELECT COL1, COL2 FROM...
3
by: Mike | last post by:
I have a view that will return say 5000 records when I do a simple select query on that view like. select * from vw_test_view How can I set up my query to only return a certain # of...
1
by: dkode8 | last post by:
Heres my problem, the first part selects a row from the database, if there is no row with the criteria it inserts a row and then returns it, the problem is the IF statement that inserts the row,...
7
by: Aaron | last post by:
Complete code follows. I am new to .NET programming (and programming in general) and I am having a difficult time understanding how to fill a variable in one sub, and then access it from...
12
by: Graham Blandford | last post by:
Hi all, Would someone be able to tell me the most 'graceful' way of removing unwanted rows from a dataset based on a condition prior to update? OR, resetting the rows all to unchanged after they...
7
by: Susan Mackay | last post by:
I have a data table that is connected to a database table with a data adapter in the 'standard' manner. However I want to be able to remove selected rows from the data table (i.e. no longer...
0
by: Maart_newbie | last post by:
Hi all, I've got a question about returning the value of a pk-column to a DataTable after inserting a row (via a data-adapter) using MySql5. Here is the SQL and code concerned: ...
1
by: Constantine AI | last post by:
Here is the situation i am currently trying to update a sales order using PHP and javascript. When you click on the edit button it brings you a new site page with existing sales order details within....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.