Embedded SQL
Embedded SQL is a methodology of inserting inline SQL statements or queries into the source of a programming language, which is called as a host language. Because the host language can’t parse SQL, the inserted SQL is parsed by an embedded SQL preprocessor.
Embedded SQL is a robust and the convenient methodology of joining the computing power of a coding language with SQL’s specialized data management and manipulation abilities.
Embedded SQL is not supported by all the relational database management systems (RDBMS). Oracle DB and PostgreSQL gives embedded SQL support. MySQL, Sybase and SQL Server 2008 do not, though support was given by earlier versions of SQL Server (2000 and 2005).
The C coding language is basically used for embedded SQL implementation. For instance, a commercial bank’s information system (IS) has a front end user interface created in the C programming language, and the IS interfaces with a back end Oracle DB database. One of the front end interface modules permits quick viewing and commission calculation for sales agents during specified periods. An inefficient approach to handling this process would be to store each commission value in a database table. However, a more effective solution is to calculate and return commission values based on unique user requests on specified dates. The application accomplishes this by embedding the SQL query within the C code, as follows:
SELECT 0.2*SALE_AMOUNT FROM TOTAL_SALES WHERE SALE_DATE=’MM/DD’YYYY’ AND AGENT_NO=xx
In this instance , the SQL statement calculates and returns the 20 percent of the sale amount from a TOTAL_SALES table, while the user is expected to input the SALE_DATE and AGENT_NO values. This SQL query is then the inserted inline into the C code of the front-end module. The C code and SQL query work together to deliver seamless user results.