2. Embedded SQL for C : Preprocessor Operation : Coding Requirements for Embedded SQL Programs : How Statements are Embedded Inside C If Blocks
 
Share this page                  
How Statements are Embedded Inside C If Blocks
As previously mentioned, the preprocessor can produce several C statements for a single embedded SQL statement. However, all of the statements that the preprocessor generates are delimited by left and right braces, composing a C block. Thus the statement:
if (!dba)
    exec sql select passwd
        into :passwd
        from security
        where usrname = :userid;
produces legal C code, even though the SQL select statement produces more than one C statement. However, two or more embedded SQL statements generate multiple C blocks, so you must delimit them yourself, just as you delimit two C statements in a single if block.
For example:
if (!dba)
 {
    exec frs message 'Confirming your user id';
    exec sql select passwd
        into :passwd
        from security
        where usrname = :userid;
 }
VMS:
Because the preprocessor generates a C block for every embedded SQL statement, the VAX C compiler may generate the Internal Table Overflow error when a single procedure has a very large number of embedded SQL statements and local variables. You can correct this problem by splitting the file or procedure into smaller components.