Embedded SQL
Computer programming method
title: "Embedded SQL" type: doc version: 1 created: 2026-02-28 author: "Wikipedia contributors" status: active scope: public tags: ["sql", "declarative-programming-languages", "query-languages", "data-modeling-languages", "database-apis", "sql-data-access"] description: "Computer programming method" topic_path: "technology/databases" source: "https://en.wikipedia.org/wiki/Embedded_SQL" license: "CC BY-SA 4.0" wikipedia_page_id: 0 wikipedia_revision_id: 0
::summary Computer programming method ::
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 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. |url=http://download.oracle.com/docs/cd/B10501_01/appdev.920/a58231/ch1.htm#2889 |title=The Module Language Concept |work=SQLModule for Ada Programmer's Guide, Release 8.0, Chapter 1. Introduction to SQLModule |publisher=Oracle Corporation |accessdate=2008-07-14}} 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.
The SQL standard SQL:2023 is available through purchase and contains chapter 21 Embedded SQL and its syntax rules.{{cite web |url=https://www.iso.org/standard/76584.html |title=SQL Standard 2023 Chapter 21 Embedded SQL |work=ISO/IEC 9075-2:2023 Information technology — Database languages — SQL — Part 2: Foundation (SQL/Foundation) |publisher=ISO |accessdate=2023-08-17
Database systems that support embedded SQL
Altibase
; C/C++ : APRE is an embedded SQL precompiler provided by Altibase Corp. for its DBMS server.
IBM Db2
IBM Db2 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.{{cite web |url=http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=/com.ibm.db2.udb.apdv.embed.doc/doc/c0007014.htm |title=DB2 Database for Linux, UNIX and Windows |work=Developing Embedded SQL Applications |publisher=IBM |accessdate=2009-04-10
IBM Informix
IBM Informix version 14.10 for Linux, Unix, and Windows supports embedded SQL for C. {{cite web|url=https://www.ibm.com/support/knowledgecenter/SSGU8G_14.1.0/com.ibm.esqlc.doc/esqlc.htm|title=Informix Dynamic Server |work=IBM® Informix® ESQL/C |publisher=IBM |accessdate=2020-03-31
Microsoft SQL Server
; C/C++ : Embedded SQL for C has been deprecated as of Microsoft SQL Server 2008 although earlier versions of the product support it.{{cite web |url=http://msdn.microsoft.com/en-us/library/ms143729.aspx |title=Deprecated Database Engine Features in SQL Server 2008 |work=SQL Server 2008 Books Online (March 2009) |publisher=Microsoft |accessdate=2009-04-10
Mimer SQL
Mimer SQL for Linux, macOS, OpenVMS and Windows support embedded SQL.{{cite web |url=https://docs.mimer.com/MimerSqlManual/latest/Manuals/Embedded_SQL/Embedded_SQL.htm |title=Embedded SQL|publisher=Mimer SQL |work=Mimer SQL Programmer's Manual latest version, Embedded SQL}} ; C/C++ : Embedded SQL for C/C++ is supported on Linux, macOS, OpenVMS and Windows. ; COBOL : Embedded SQL for COBOL is supported on OpenVMS. ; Fortran : Embedded SQL for Fortran is supported on OpenVMS.
Oracle Database
; Ada : ProAda was officially desupported by Oracle in version 7.3. Starting with Oracle8, ProAda was replaced by SQL*Module but appears to have not been updated since.{{cite web |url=http://download.oracle.com/docs/cd/B10501_01/server.920/a96530/migcompa.htm#1010868 |title=Ada Support in Version 8 |work=Oracle9i Database Migration, Release 2 (9.2), Chapter 5. Compatibility and Interoperability |publisher=Oracle Corporation |accessdate=2008-07-14
; C/C++ : Pro*C became ProC/C++ with Oracle8. ProC/C++ is currently supported as of Oracle Database 11g.
; COBOL : ProCOBOL is currently supported as of Oracle Database 11g*.
; Fortran : Pro*FORTRAN is no longer updated as of Oracle8 but Oracle will continue to issue patch releases as bugs are reported and corrected.
; Pascal : Pro*Pascal was not released with Oracle8.
; PL/I : ProPL/I was not released with Oracle8. The ProPL/I Supplement to the Oracle Precompilers Guide, however, continued to make appearances in the Oracle Documentation Library until release 11g. As of release 12c, the ProPL/I has been removed from the Oracle Documentation Library.{{cite web |url=http://download.oracle.com/docs/cd/A64702_01/doc/server.805/a58232/ch01.htm#505 |title=Language Alternatives |work=ProCOBOL Precompiler Programmer's Guide, Release 8.0, Chapter 1. Introduction |publisher=Oracle Corporation |accessdate=2008-07-14
PostgreSQL
; C/C++ : ECPG is part of PostgreSQL since version 6.3. ; COBOL : Cobol-IT is now distributing a COBOL precompiler for PostgreSQL : Micro Focus provides support via their OpenESQL preprocessor
SAP Sybase
SAP Sybase ASE 15.7 supports embedded SQL for C and COBOL as part of the Software Developer Kit Sybase.{{cite web |url=http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/embeddedsql |title=EmbeddedSQL |work=SAP Sybase Products |publisher=SAP Sybase |accessdate=2012-09-05 |archive-date=2009-10-23 |archive-url=https://web.archive.org/web/20091023214433/http://www.sybase.com/products/allproductsa-z/softwaredeveloperkit/embeddedsql |url-status=dead
SAP Sybase SQL Anywhere supports embedded SQL for C and C++ as part of the SQL Anywhere database management system SQL Anywhere.{{cite web |url=http://www54.sap.com/pc/tech/database/software/sybase-sql-anywhere/index.html |title=SAP Sybase SQL Anywhere |work=SAP Sybase Products |publisher=SAP Sybase |accessdate=2013-05-02 |archive-url=https://web.archive.org/web/20130501030013/http://www54.sap.com/pc/tech/database/software/sybase-sql-anywhere/index.html |archive-date=2013-05-01 |url-status=dead
SAP Sybase IQ supports embedded SQL for C and C++ as part of the Sybase IQ database management system Sybase IQ.{{cite web |url=http://www54.sap.com/pc/tech/database/software/sybase-iq-big-data-management/index.html |title=SAP Sybase IQ |work=SAP Sybase Products |publisher=SAP Sybase |accessdate=2013-05-02 |archive-url=https://web.archive.org/web/20130504025213/http://www54.sap.com/pc/tech/database/software/sybase-iq-big-data-management/index.html |archive-date=2013-05-04 |url-status=dead
Embedded SQL through domain-specific languages
- LINQ-to-SQL embeds a SQL-like language into .NET languages.
- JPA embeds a SQL-like language through Criteria API into Java.
- jOOQ embeds a SQL-like language into Java.
References
::callout[type=info title="Wikipedia Source"] This article was imported from Wikipedia and is available under the Creative Commons Attribution-ShareAlike 4.0 License. Content has been adapted to SurfDoc format. Original contributors can be found on the article history page. ::