Professional Documents
Culture Documents
Content Beyond Syllabus Embedded SQL
Content Beyond Syllabus Embedded SQL
EMBEDDED SQL
Drawbacks of SQL:
1. SQL does not provide the full expressive power of a general-purpose language.
2. Nondeclarative actions such as printing a report, interacting with a user cannot be done
from within SQL.
The SQL standard defines embeddings of SQL in a variety of programming
languages, such as C, Cobol, Pascal, Java, PL/I and Fortran.
A language in which SQL queries are embedded is referred to as a host language, and
the SQL structures permitted in the host language constitute embedded SQL.
Syntax:
EXEC SQL < any valid update, insert, or delete > END-EXEC.
Exercise:
To find the names and cities of residence of customers who have more than amount (host
language variable) in any account.
EXEC SQL
Declare c cursor for
select cust-name, cust-city
from depositor, customer, account
where depositor.cust-name = customer.cust-name and
account.account-number = depositor.account-number and
account.balance >:account
END-EXEC
RESULT: