ALL embedded SQL statements must be preceded with EXEC SQL and end with a semicolon (;).
There are two groups of embedded SQL statements. Standard SQL statements are used by simply placing them in a C program enclosed with EXEC SQL and a semicolon (;). CONNECT, DELETE, SELECT, SET, and UPDATE have additional formats only available in embedded SQL. The additional formats fall into the second category of embedded SQL specific statements.
Several SQL statements are specific to embedded SQL and can only be used in a C program.
Standard data manipulation and data definition statements can be used from embedded SQL applications. In addition, the following statements are specifically for embedded SQL programming:
- ALLOCATE DESCRIPTOR statement [ESQL] – allocate memory for a descriptor.
- CLOSE statement [ESQL] [SP] – close a cursor.
- CONNECT statement [ESQL] [Interactive SQL] – connect to the database.
- DEALLOCATE DESCRIPTOR statement [ESQL] – reclaim memory for a descriptor.
- Declaration section [ESQL] – declare host variables for database communication.
- DECLARE CURSOR statement [ESQL] [SP] – declare a cursor.
- DELETE statement (positioned) [ESQL] [SP] – delete the row at the current position in a cursor.
- DESCRIBE statement [ESQL] – describe the host variables for a particular SQL statement.
- DISCONNECT statement [ESQL] [Interactive SQL] – disconnect from database server.
- DROP STATEMENT statement [ESQL] – free resources used by a prepared statement.
- EXECUTE statement [ESQL] – execute a particular SQL statement.
- EXPLAIN statement [ESQL] – explain the optimization strategy for a particular cursor.
- FETCH statement [ESQL] [SP] – fetch a row from a cursor.
- GET DATA statement [ESQL] – fetch long values from a cursor.
- GET DESCRIPTOR statement [ESQL] – retrieve information about a variable in a SQLDA.
- GET OPTION statement [ESQL] – get the setting for a particular database option.
- INCLUDE statement [ESQL] – include a file for SQL preprocessing.
- OPEN statement [ESQL] [SP] – open a cursor.
- PREPARE statement [ESQL] – prepare a particular SQL statement.
- PUT statement [ESQL] – insert a row into a cursor.
- SET CONNECTION statement [Interactive SQL] [ESQL] – change active connection.
- SET DESCRIPTOR statement [ESQL] – describe the variables in a SQLDA and place data into the SQLDA.
- SET SQLCA statement [ESQL] – use a SQLCA other than the default global one.
- UPDATE (positioned) statement [ESQL] [SP] – update the row at the current location of a cursor.
- WHENEVER statement [ESQL] – specify actions to occur on errors in SQL statements.