Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2006
    Posts
    2

    Question Unanswered: Scope of whenever in embedded SQL

    Suppose we have the following C fragment of code:
    Code:
    exec sql whenever sqlerror stop;
    exec sql connect ...;
    .
    .
    .
    goto l7;
    .
    .
    .
    exec sql whenever sqlerror goto l2;
    exec sql select ...;
    .
    .
    .
    l7;
    .
    .
    l2;
    .
    .
    .
    Then, after the goto l7, the flow of our program will jump to l7. After l7 and onwards, which whenever statement does it apply?

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    Homework, homework, homework...
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

  3. #3
    Join Date
    Apr 2006
    Posts
    2
    It's not homework. I am just doing self-study.

    I read it from the book "Relational Database Systems" by Dan A. Simovici, Richard L. Tenney, published by Academic press, in 1995.

    In chapter 4, Embedded SQL, on page 153, after the above code (I changed lab to l), in the second last paragaph, it says:

    "The scope of the first whenever extends to the statement that precedes the second whenever. If an error occurs in the select statement, the execution wll jump to the statement labeled lab2. The jump goto lab7 that will make the control flow bypass the second select has no impact whatsoever on the effect of the second whenever on the select, because the scope of any whenever has a strictly lexical, static character."
    From the above explanation, my understanding is that the second whenever will apply after l7 and onwards.

    I want to make sure that my understanding is correct. That's why I asked this. I tried to search for it in the esql documentation of Ingres but couldn't find.
    Last edited by noblesilence; 05-16-06 at 02:14.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •