![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Here is a stored procedure. Questions: 1. When the stored procedure is executed in Java in a WebLogic cluster the procedure hangs. A benign SQLWarning is set off - but that has the effect of calling the continue handler - which does nothing - and then the procedure times out. Is there a way to make it to make it so the continue handler works as a do-nothing no-op? 2. Is there a scoping rule that says that all fetch statements must occur within a while loop? 3. Should an exit handler have an exit statement in it? And what is a clean way to cause an exception to test the handler? Thanks. CREATE PROCEDURE SOME_SCHEMA.SOME_PROC( OUT a_sqlcode * * * * INTEGER ,OUT a_sqlstate * * * *CHAR(5) ,OUT a_error_msg * * * VARCHAR(2000) ) * LANGUAGE SQL * NOT DETERMINISTIC * CALLED ON NULL INPUT * MODIFIES SQL DATA BEGIN * *DECLARE SQLSTATE * * * * * CHAR(5) * DEFAULT '00000'; * *DECLARE SQLCODE * * * * * *INTEGER * DEFAULT 0; * *DECLARE l_update_count * * * * * int *default 0; * *DECLARE l_counter * * * * * * * *int *default 0; * *DECLARE l_last_executed_date_p1 *timestamp; * *DECLARE l_commit_freq * * * * * *int *default 1000; * *DECLARE EXIT HANDLER FOR SQLEXCEPTION * * * BEGIN * * * * * GET DIAGNOSTICS EXCEPTION 1 a_error_msg = *MESSAGE_TEXT; * * * * * VALUES (SQLCODE,SQLSTATE) INTO a_sqlcode,a_sqlstate; * * * END; * *DECLARE EXIT HANDLER FOR NOT FOUND * * * BEGIN commit ; * * * END; BEGIN * * DECLARE cs_cursor CURSOR WITH HOLD FOR * * SELECT **some sql* * * * *FOR UPDATE; * * OPEN cs_cursor; * * set l_last_executed_date_p1 = current date; * * WHILE 1 =1 * * DO FETCH cs_cursor into *some sql* * * * * UPDATE *some sql* * * * * *WHERE current of cs_cursor; * * * * SET l_update_count = l_update_count + 1; * * * * SET l_counter = l_counter + 1; * * * * IF * l_counter = l_commit_freq * * * * THEN * * * * * * COMMIT WORK; * * * * * * SET l_counter = 0; * * * * END IF; * * END WHILE; * * CLOSE cs_cursor; END@ |
![]() |
| Thread Tools | |
| Display Modes | |
| |