Embedded SQL overview

Embedded SQL is a superset of Transact-SQL that lets you place Transact-SQL statements in application programs written in languages such as C and COBOL.

Open Client™ Embedded SQL enables you to create programs that access and update Adaptive Server data. Embedded SQL programmers write SQL statements directly into an application program written in a conventional programming language such as C or COBOL. A preprocessing program—the Embedded SQL precompiler—processes the completed application program, resulting in a program that the host language compiler can compile. The program is linked with Open Client Client-Library™ before it is executed.

Embedded SQL is one of the two programming methods Sybase provides for accessing Adaptive Server. The other programming method is the call-level interface. With the call-level interface, you place Client-Library calls directly into an application program, then link with Client-Library.

You can place Embedded SQL statements anywhere in a host program and mix them with host language statements. All Embedded SQL statements must begin with the keywords exec sql and end with a semicolon (;).

You can use host variables in Embedded SQL statements to store data retrieved from Adaptive Server and as parameters in Embedded SQL statements, such as in the where clause of a select statement. In dynamic SQL, host variables can also contain text for Embedded SQL statements.

After you write an Embedded SQL program, run it through the precompiler, which translates the Embedded SQL statements into Client-Library function calls.