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 />

Example<br />

320<br />

BEGIN-END DECLARE SECTION<br />

Declares variables and types used by the precompiler. Any variables you refer to in an<br />

embedded <strong>SQL</strong> statement must be declared in a DECLARE SECTION. This section starts with a<br />

BEGIN DECLARE SECTION statement and ends with an END DECLARE SECTION statement. Each<br />

variable must be declared as a host language data type.<br />

EXEC <strong>SQL</strong> BEGIN DECLARE SECTION<br />

host_lang_type variable_name ;<br />

.<br />

.<br />

.<br />

EXEC <strong>SQL</strong> END DECLARE SECTION<br />

host_lang_type variable_name ;<br />

A conventional C Language variable declaration. This form of variable declaration<br />

conforms to the ANSI standard for the C Language.<br />

Syntax<br />

{ char | short | long | float | double }<br />

EXEC <strong>SQL</strong> BEGIN DECLARE SECTION ;<br />

short InvTransNum_v ;<br />

short Qty_v ;<br />

short OrderNum_v ;<br />

EXEC <strong>SQL</strong> END DECLARE SECTION ;<br />

Notes • The C Language type int is not supported by E<strong>SQL</strong>. Type int maps to 16 or 32 bits,<br />

depending on the machine architecture. This can create rounding errors at run time, as<br />

values are passed across different machine architectures.<br />

• Variables you declare in a BEGIN-END DECLARE SECTION can be used in C Language<br />

statements as if they are declared outside the DECLARE SECTION.<br />

• The scope of variables follows host language scoping rules. The E<strong>SQL</strong> variables are not<br />

visible outside the file in which they are declared.<br />

DECLARE sections are permissible only where host language declarations are permissible<br />

in the host language syntax. This restriction is due to how DECLARE SECTION blocks are<br />

translated into the main body of host language declarations.<br />

• Avoid DECLARE sections in header files that are included by more than one source file. This<br />

can cause duplicate variables with the same name.<br />

• The form of the variable created by E<strong>SQL</strong> for each type is specified so that it can be<br />

manipulated from host language statements. Declaring variables allows you to use the<br />

variables in both host language and embedded <strong>SQL</strong> statements.

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

Saved successfully!

Ooh no, something went wrong!