2. Embedded SQL for C : C++ Programming : How to Create ESQL/C++ Programs : How to Declare Function Parameters
 
Share this page                  
How to Declare Function Parameters
To declare function parameters to ESQL/C++, use local variables. In the following example, the local variables ptrsqlvar1 and locsqlvar2 are declared to the ESQL precompiler. The function parameters sqlvar1 and sqlvar2 are copied to ptrsqlvar1 and locsqlvar2 when their values are required for use in ESQL statements.
int myfunc (int sqlvar1, int sqlvar2)
 {
  exec sql begin declare section
    int *ptrsqlvar1;   /* Use local pointer */
    int locsqlvar2;   /*Use local variable */
  exec sql end declare section
  ptrsqlvar1 = &sqlvar1;
  locsqlvar2 = sqlvar2;
 // Use local variables in SQL statement:
  exec sql insert into mytable
    values (ptrsqlvar1, locsqlvar2);
...
 }