Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Pro*C/C++ and the goto operator
On Tue, 05 Oct 1999 08:30:22 -0400 Kenneth C Stahl
<BlueSax_at_Unforgettable.com> wrote:
[snip]
> Oracle had a very good reason for including the
>
> EXEC SQL WHENEVER SQLERROR GOTO mylabel;
>
> functionality. The basic intention is that if an erorr does not occur,
> execution will continue with the next statement after whatever SQL
> statement is executed. However, if an error occurs the exeucution will
> branch around the this code to an error handler. For example, here is a
> simple function which uses this logic:
>
> static int Ora_Commit(void)
> {
> EXEC SQL WHENEVER SQLERROR GOTO SQLERR;
> EXEC SQL COMMIT WORK;
> return(0);
>
> SQLERR:
> return(1);
> }
>
> I think this is extremely clean to anyone who understand C and it solves
> the problem succiently and portably.
>
[snip]
The example is convincing.
I think, it is worth using this approach.
P.S. This construction seems to be like switch-operator in C.
Thanks, Alex