Start from specific sql in Stored Procedure

Database
Enthusiast

Start from specific sql in Stored Procedure

Is it possible to start execution of a Stored Procedure from a specific location?

My SP has a series of sqls with STEP_ID assigned. I need to pass a STEP_ID value and excute only from that STEP_ID till end. Note: STEP_ID values may not be sequential

Eg:

Replace Procedure ABC (
    IN STEP_ID  INTEGER
)

BEGIN

SET STEP_ID = 51;

INSERT INTO ....

SET STEP_ID = 53;

UPDATE ....
2 REPLIES
Supporter

Re: Start from specific sql in Stored Procedure

check the manuals 

you have

if then else and

case construct to achive what you want.

Ulrich

Enthusiast

Re: Start from specific sql in Stored Procedure

Following might help you

Replace Procedure ABC (IN STEP_ID  INTEGER)
Declare RESUME_NEXT Varchar(10)
BEGIN
SET RESUME_NEXT = 'false';
IF (RESUME_NEXT = 'true' OR STEP_ID = 51) THEN
INSERT INTO ....
SET RESUME_NEXT = 'true';
END IF;

IF (RESUME_NEXT = 'true' OR STEP_ID = 53) THEN
UPDATE ....
SET RESUME_NEXT = 'true';
END IF;


PS: Please bear with syntax.