23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

E<strong>SQL</strong> elements and statements<br />

Syntax<br />

Examples<br />

342<br />

Authorization<br />

None<br />

Related statements<br />

CONNECT, DISCONNECT<br />

WHENEVER<br />

Specifies actions for three <strong>SQL</strong> run-time exceptions.<br />

WHENEVER<br />

{ NOT FOUND | <strong>SQL</strong>ERROR | <strong>SQL</strong>WARNING }<br />

{ STOP | CONTINUE | { GOTO | GO TO } host_lang_label } ;<br />

{ NOT FOUND | <strong>SQL</strong>ERROR | <strong>SQL</strong>WARNING }<br />

• The NOT FOUND exception is set when sqlca.sqlcode is set to <strong>SQL</strong>_NOT_FOUND.<br />

• The <strong>SQL</strong>ERROR exception is set when sqlca.sqlcode is set to a negative value.<br />

• The <strong>SQL</strong>WARNING exception is set when sqlca.sqlwarn[ 0 ] is set to W after a<br />

statement is executed.<br />

{ STOP | CONTINUE | GOTO | GO TO } host_lang_label }<br />

• The STOP exception results in the E<strong>SQL</strong> program stopping execution.<br />

• The CONTINUE exception results in the E<strong>SQL</strong> program continuing execution. The<br />

default exception is to CONTINUE.<br />

• GOTO | GO host_lang_label results in the E<strong>SQL</strong> program execution to branch to the<br />

statement corresponding to the host_lang_label.<br />

/*<br />

** Name WHENEVER routine to handle <strong>SQL</strong>ERROR condition.<br />

*/<br />

EXEC <strong>SQL</strong> WHENEVER <strong>SQL</strong>ERROR GOTO mainerr ;<br />

/*<br />

** Name WHENEVER routines to handle NOT FOUND and <strong>SQL</strong>ERROR<br />

*/<br />

EXEC <strong>SQL</strong> WHENEVER <strong>SQL</strong>ERROR GOTO nodyn ;<br />

EXEC <strong>SQL</strong> WHENEVER NOT FOUND GOTO nodyn ;<br />

Notes • You can place multiple WHENEVER statements for the same exception in a source file. Each<br />

WHENEVER statement overrides the previous WHENEVER statement specified for the same<br />

exception.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!