Embedded SQL statement

Every embedded SQL Statement has the same general structure shown as below. For each query the programmer may specify the data bases where the query has to be applied. If the data base is not explicitly specified, the default data base connection is assumed.

Syntax:

     <embedded SQL statement> ::=
              <SQL prefix>
              statement or declaration
              [ <SQL terminator> ]

     <statement or declaration> ::=
              | <include clause>
              | <database clause>
              | <connect clause>
              | <declare clause>
              | <temporary table declaration>
              | <dynamic sql clause>
              | <query clause>
              | <fetch clause>
              | <embedded SQL declare section>
                <embedded exception declaration>
	      ;

     <SQL prefix> ::=
                EXEC SQL [ <DB clause> ] [ <for clause>]

     <SQL terminator>  ::=
                END-EXEC
              | <semicolon> 
              | <right paren> 
              ;

     <DB clause> ::= AT <name> 
     <for clause> ::= FOR <expression> (not yet implemented)

     <include clause> ::=
                <include_sqlca_clause>                
              | <include_handles>
              ;

     <declare clause> ::=
                <declare_db_clause>
              | <declare_table_clause>
              | <declare cursor>
              ;

Example 14-1. Embedded SQL Statements

      EXEC SQL AT db01 select * from employees ;
   

This example sends a query to the db01.

All components of the ESQL statement which are not part of the esql grammar will be copied directly into the query which is to be sent to the dbcs.