0

What is scope of ContinueHandler in below scenario?. Is stmt2 covered for exception handling by continue handler?

BEGIN 
    DECLARE CONTINUE HANDLER FOR ...;  -- handler H1
    stmt1;
    stmt2;  
  END;
2
  • How are you using the handler? with a cursor or not? Commented Apr 20, 2014 at 10:59
  • @Ravinder with cursor. Commented Apr 20, 2014 at 11:22

1 Answer 1

2

As documented under Scope Rules for Handlers:

A handler declared in a BEGIN ... END block is in scope only for the SQL statements following the handler declarations in the block. If the handler itself raises a condition, it cannot handle that condition, nor can any other handlers declared in the block. In the following example, handlers H1 and H2 are in scope for conditions raised by statements stmt1 and stmt2. But neither H1 nor H2 are in scope for conditions raised in the body of H1 or H2.

BEGIN -- outer block
  DECLARE EXIT HANDLER FOR ...;  -- handler H1
  DECLARE EXIT HANDLER FOR ...;  -- handler H2
  stmt1;
  stmt2;
END;
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks but, I went through the doc before posting, lets say H2 does not exit in above code An exception occurs in stmt2, will declare continue handler catch this?
@Abhijeet: Yes, the handler remains in scope for both statements. The documentation elected to illustrate this using EXIT HANDLER, but could just as well have done so using CONTINUE HANDLER.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.