Microsoft
Software
Hardware
Network
Question : How to update a table based on temporary table result set - using db2 stored procedures
Hi ,
I have a scenario which involved in three steps.
1.fetch data from the tableA.
2.Insert the fetched data from tableA data into temp table.
3.update the tableB based on the temp table.
I am able to do first 2 steps, but when i am executing 3 rd step iam getting -811.
I am not sure how to handle cursors.Can you please let me know
how can i update tableb based on the temp table result set.
Thanks in advance for your help.
REATE PROCEDURE TXTPROC4 ( )
DYNAMIC RESULT SETS 1
LANGUAGE SQL
--------------------------
----------
----------
----------
----------
------
-- SQL Stored Procedure
--------------------------
----------
----------
----------
----------
------
P1: BEGIN
-- Declare cursor
DECLARE i integer DEFAULT 0;
DECLARE counter integer DEFAULT 1;
DECLARE GLOBAL TEMPORARY TABLE SESSION.TEMP_TABLE
(Tcol1 BIGINT,
Tcol2 VARCHAR(30)
) ON COMMIT PRESERVE ROWS NOT LOGGED WITH REPLACE;
INSERT INTO SESSION.TEMP_TABLE
(select col2 from tablea where col1 IN ('TEST', 'TEST2')) ;
COMMIT;
P2 : BEGIN
DECLARE c2 CURSOR WITH RETURN TO CLIENT FOR
SELECT * FROM session.temp_table ;
OPEN c2;
fetch c2 into counter ;
while ( i < counter) do
UPDATE tableb SET NAME = 'TEST FOR TEMP'
where col1 = select tcol1 from session.temp_table ;
set i = i + 1 ;
end while ;
END;
END
Answer : How to update a table based on temporary table result set - using db2 stored procedures
Refer to this online example
http://www.asp.net/ajax/aj
axcontrolt
oolkit/Sam
ples/Calen
dar/
Calend
ar.aspx
Hope this will help you
Random Solutions
how to implement a pac file using group policy
How do most developer handle localization in .NET?
Win2000 Terminal Server and your terminal services client license will expire in x days
Blackberry browser 400 error - socketexception Connection reset
ASP Connection String vs. Database Access DLL
SQL has slowed down after DPM agent install
Blank screen After WIn XP splash screen.
530 error bounced email when sending to any sbcglobal.net address from our sbs 2003 server. The ISP is sbcglobal DSL line.
No Networking Installed on Windows 2008 VM After Migrating From VMWARE Server to ESXi Server
Dynamically Label Radio Button Lists in ASP.net