Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Stored procedure stuck in a loop

Status
Not open for further replies.

vskr72

IS-IT--Management
Nov 15, 2003
1
US
The following procedure is stuck in a loop. All I am trying to do is read some columns from a table, load it in TEMP table and write it to a file. Can someone help me here?

{code}
drop procedure Proc_Test

CREATE PROCEDURE SVITTALAM.Proc_Test
(OUT p_Cnt VARCHAR(4),
OUT p_SQLSTATE VARCHAR(100)
)
LANGUAGE SQL
BEGIN

DECLARE V_DYNAMIC VARCHAR(100) ; -- (2)
DECLARE v_Tsql VARCHAR(100) ;
DECLARE v_Tid VARCHAR(100) ;
DECLARE SQLSTATE CHAR(5) DEFAULT '00000';
DECLARE v_SQLSTATE CHAR(5) DEFAULT '00000'; -- (2)
DECLARE cursor1 CURSOR with hold FOR
SELECT ID,SQLTEXT FROM test;--

DECLARE CONTINUE HANDLER FOR SQLWARNING, SQLEXCEPTION, NOT FOUND
SET p_SQLSTATE = SQLSTATE;

DECLARE GLOBAL TEMPORARY TABLE Rslt (
sql_id varchar(100),
cnt Varchar(4),
sql_state varchar(6)
)
on commit
preserve rows
not logged ;

Open cursor1;
A:
Loop
fetch cursor1 into v_Tid, v_Tsql;


insert into session.Rslt values(v_Tsql, v_Tid, '0');
commit;

call sysproc.admin_cmd('export to c:\test\test.csv of del select * from session.Rslt') ;

end loop A;

close cursor1;

drop table session.Rslt;
END
{code}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top