Chapter 3: Embedded SQL Statements

Embedded SQL statements work somewhat differently from, or are in addition to, standard Transact-SQL statements.

You can include Embedded SQL statements in portions of your C code where C functions or routines can be placed. Each Embedded SQL statement must begin with the introductory keyword EXEC SQL and end with a semicolon (;) to distinguish Embedded SQL statements from the rest of the C source code. The maximum size of a single Embedded SQL statement is 8,191 characters for 16-bit Windows and 19,999 characters for Windows NT.

Embedded SQL keywords and statements are not case-sensitive. For example, the following Embedded SQL statement fragments are equivalent:


EXEC SQL CONNECT TO
exec sql connect to
Exec Sql Connect To

However, the names that are specified for Embedded SQL names such as cursors, prepared statements, and connections are case-sensitive. The same case must be used to declare and use these names. For example, the following fragments declare two different cursors:


DECLARE CUR_NAME CURSOR
DECLARE cur_name CURSOR

The sort order of the Microsoft SQL Server you are connecting to determines whether other words are case-sensitive. Note that hyphens (-) are not permitted in Transact-SQL identifiers such as table and column names.

Note

The Transact-SQL keyword null should not be in uppercase in Embedded SQL programs to avoid conflict with the C keyword NULL. Also, the Embedded SQL keyword delete and the Transact-SQL keyword in should not be in uppercase in applications for 32-bit Windows to avoid conflict with 32-bit Windows–defined constants in WINDOWS.H.