DBMSSQL

Embedded SQL

EMBEDDED SQL

Programs written in high level languages such as C/C++ can use EMBEDDED SQL to access and update data stored in a database. Thus embedded SQL helps programmers in manipulating as well as updating a database easily. All queries are sent by the host program to the database management system (DBMS) through embedded SQL. The DBMS software package processes such queries and sends the result to the program, one tuple (record) at a time.

The host program that incorporates embedded SQL within itself, must be processed by a special pre-processor before compilation. The special processor replaces the SQL syntax with the host language syntax and declarations. This allows for the run time execution of database queries. For example Pre*C/C++ is a pre-compiler that converts SQL statements into C statements so that the resulting output file can then be compiled by a C/C++ compiler.

For special processor to distinguish embedded SQL statements from the host language statements, we use EXEC SQL. This is done in the following statement.

EXEC SQL <EMBEDDED SQL STATEMENTS> END EXEC.

WHY EMBEDDED SQL? 

SQL is a non procedural language. Although its non procedural character gives many specialties. Inside a host program, SQL will be used to perform the following operations:

Passing values from the host program to the database table. 

Operating on database table. passing results outputs to the host program. 

In order to embed SQL into another programming language you must use a software package that provides support for the programming language as well as SQL.

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also
Close
Back to top button