Embedded SQL


Embedded SQL is a method of combining the computing power of a programming language and the database manipulation capabilities of SQL. Embedded SQL statements are SQL statements written inline with the program source code, of the host language. The embedded SQL statements are parsed by an embedded SQL preprocessor and replaced by host-language calls to a code library. The output from the preprocessor is then compiled by the host compiler. This allows programmers to embed SQL statements in programs written in any number of languages such as :Category:C programming language family|C/C++, COBOL and Fortran. This differs from SQL-derived programming languages that don't go through discrete preprocessors, such as PL/SQL and T-SQL.
The SQL standards committee defined the embedded SQL standard in two steps: a formalism called Module Language was defined, then the embedded SQL standard was derived from Module Language. The SQL standard defines embedding of SQL as embedded SQL and the language in which SQL queries are embedded is referred to as the host language. A popular host language is C. Host language C and embedded SQL, for example, is called Pro*C in Oracle and Sybase database management systems, ESQL/C in Informix, and ECPG in the PostgreSQL database management system.
SQL may also be embedded in languages like PHP etc.

Systems that support embedded SQL

Altibase

; C/C++

IBM DB2

version 9 for Linux, UNIX and Windows supports embedded SQL for C, C++, Java, COBOL, FORTRAN and REXX although support for FORTRAN and REXX has been deprecated.

IBM Informix

version 14.10 for Linux, Unix, and Windows supports embedded SQL for C.

Microsoft SQL Server

; C/C++

Mimer SQL

for Linux, macOS, OpenVMS and Windows support embedded SQL.
; C/C++
; COBOL
; Fortran

Oracle Database

; Ada
; C/C++
; COBOL
; Fortran
; Pascal
; PL/I

PostgreSQL

; C/C++
; COBOL

Raima Database Manager (RDM)

supports embedded SQL for C/C++ and SQL PL.

SAP Sybase

SAP Sybase ASE 15.7 supports embedded SQL for C and COBOL as part of the Software Developer Kit Sybase.
SAP Sybase SQL Anywhere supports embedded SQL for C and C++ as part of the SQL Anywhere database management system SQL Anywhere.
SAP Sybase IQ supports embedded SQL for C and C++ as part of the Sybase IQ database management system Sybase IQ.

Embedded SQL through domain-specific languages