What is embedded SQL, embedded SQL is the one that combines the high-level language with the DB language like SQL. It allows the application languages to communicate with DB and get the requested result.
Embedded SQL is a super-set of Transact-SQL that lets you place Transact-SQL statements in application programs written in languages such as C and COBOL.
The high-level languages which support embedding SQLs within it are also known as the host language. There are different host languages that support embedding SQL within it like C, C++, ADA, Pascal, FORTRAN, Java, etc. When SQL is embedded within C or C++, then it is known as Pro*C/C++ or simply Pro*C language. Pro*C is the most commonly used embedded SQL. Let us discuss below embedded SQL with respect to the C language.
Main features of Embedded SQL
Embedded SQL provides several advantages over a call-level interface:
- Embedded SQL is easy to use because it is simply Transact-SQL with some added features that facilitate using it in an application.
- It is an ANSI/ISO-standard programming language.
- It requires less coding to achieve the same results as a call-level approach.
- Embedded SQL is essentially identical across different host languages. Programming conventions and syntax change very little. Therefore, to write applications in different languages, you need not learn a new syntax.
- The precompiler can optimize execution time by generating stored procedures for the Embedded SQL statements.
Difference between Static(Embedded) and Dynamic SQL
Static or Embedded SQL are SQL statements in an application that do not change at runtime and, therefore, can be hard-coded into the application. Dynamic SQL is SQL statements that are constructed at runtime; for example, the application may allow users to enter their own queries.
Dynamic SQL is a programming technique that enables you to build SQL statements dynamically at runtime. You can create more general-purpose, flexible applications by using dynamic SQL because the full text of a SQL statement may be unknown at compilation.