Stop executing stored procedure
Posted in 2006
Topics: Stored Procedures & SPL
Hi,
How can I stop executing procdure after some condition?
e.g.
create procedure myproc(nr integer)
if nr > 0 then
'here I want to stop executing and exit procedure'
end if
.
.
.
end procedure;
Thanks in advance,
Max
IF CONDITION THEN
RETURN;
END IF
Paul Watson
Tel: +44 1414161772
Mob: +44 7818003457
Web: www.oninit.com
GO FURTHER with DB2
GET THERE FASTER with Informix.
Attend the IDUG 2006 European Conference.
Vienna, Austria. 2-6 October 2006
Visit http://www.iiug.org/conf for more information.
-----Original Message-----
From: maxskalski@gmail.com [mailto:maxskalski@gmail.com]
Posted At: 03 August 2006 06:53
Posted To: comp.databases.informix
Conversation: Stop executing stored procedure
Subject: Stop executing stored procedure
Hi,
How can I stop executing procdure after some condition?
e.g.
create procedure myproc(nr integer)
if nr > 0 then
'here I want to stop executing and exit procedure'
end if
.
.
.
end procedure;
Thanks in advance,
Max
There is an exit statement in spl. You can exit any for or while loop by using it.
Here's a section from the manual
The following example uses an EXIT FOR statement. In the FOR loop, when j becomes 6, the IF condition i = 5 in the WHILE loop is true. The FOR loop stops executing, and the SPL procedure continues at the next statement outside the FOR loop (in this case, the END PROCEDURE statement). In this example, the procedure ends when j equals 6:
CREATE PROCEDURE ex_cont_ex()
DEFINE i,s,j, INT; FOR j = 1 TO 20
IF j > 10 THEN
CONTINUE FOR;
END IF
LET i,s = j,0;
WHILE i > 0
LET i = i -1;
IF i = 5 THEN
EXIT FOR;
END IF
END WHILE
END FOR
END PROCEDURE
========================
-<<Floyd Wellershaus>>-
Database Administrator
Unix Administrator
email: fwellers@yahoo.com
Home: 703-430-0805
Cell: 703-477-6045
========================
http://www.one.org/
----- Original Message ----
From: maxskalski@gmail.com
To: informix-list@iiug.org
Sent: Thursday, August 3, 2006 7:53:16 AM
Subject: Stop executing stored procedure
Hi,
How can I stop executing procdure after some condition?
e.g.
create procedure myproc(nr integer)
if nr > 0 then
'here I want to stop executing and exit procedure'
end if
.
.
.
end procedure;
Thanks in advance,
Max
_______________________________________________
Informix-list mailing list
Informix-list@iiug.org
http://www.iiug.org/mailman/listinfo/informix-list
On 3 Aug 2006 04:53:16 -0700, maxskalski@gmail.com wrote: > How can I stop executing procdure after some condition? > e.g. > > if nr > 0 then > 'here I want to stop executing and exit procedure' > end if This looks like it might be an error condition - maybe you should use RAISE instead of the EXIT and RETURN options already suggested. Error -745 is reserved for your use; you can generate a message text of your own choosing. -- Jonathan Leffler #include <disclaimer.h> Email: jleffler@earthlink.net, jleffler@us.ibm.com Guardian of DBD::Informix v2005.02 -- http://dbi.perl.org/
Jonathan Leffler wrote: > On 3 Aug 2006 04:53:16 -0700, maxskalski@gmail.com wrote: >> How can I stop executing procdure after some condition? >> e.g. >> >> if nr > 0 then >> 'here I want to stop executing and exit procedure' >> end if > > > This looks like it might be an error condition - maybe you should use > RAISE instead of the EXIT and RETURN options already suggested. Error > -745 is reserved for your use; you can generate a message text of your > own choosing. > > ITYM -746 -- rh