Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

CONTENT BEYOND SYLLABUS

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

Updating the SAL and COMM columns in the EMP table:

EXEC SQL UPDATE EMP


SET SAL = :SALARY, COMM = :COMMISSION
WHERE EMPNO = :EMP-NUMBER
END-EXEC.

RESULT:

Thus the study of embedded SQL is completed successfully.

You might also like