0% found this document useful (0 votes)
15 views1 page

PL SQL Embedded Statements

Uploaded by

baraaadil555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

PL SQL Embedded Statements

Uploaded by

baraaadil555
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

PL/SQL - Embedded Statements

1. What do you mean by an embedded statement?


An embedded statement refers to a SQL query, like a SELECT statement, that is included
within a PL/SQL block. These statements are used to interact with the database to retrieve
or manipulate data, and their results are stored in PL/SQL variables or records for further
use within the program.

2. What is the difference between a normal SELECT and an embedded


SELECT statement?
A normal SELECT statement (used in SQL) retrieves data directly from the database and
displays the result to the user or a tool like iSQL*Plus. An embedded SELECT statement
(used in PL/SQL) retrieves data from the database and stores the result into PL/SQL
variables or records using the INTO clause for further processing within the program.

3. Can you use the same name for a variable and a column?
Yes, but it's not recommended as it can lead to ambiguity. If a variable and a column have
the same name, PL/SQL will give preference to the variable by default. To avoid confusion,
you can use aliases in the SQL statement to distinguish between the column and the
variable.

Example:

SELECT column_name
INTO variable_name
FROM table_name
WHERE column_name = variable_name;

4. What is the rule to be remembered when using the INTO clause?


The number of variables in the INTO clause must match the number of columns in the
SELECT list. The data types of the variables must be compatible with the data types of the
corresponding columns or expressions in the SELECT list. The SELECT query must return
exactly one row; otherwise, errors like NO_DATA_FOUND (if no rows are returned) or
TOO_MANY_ROWS (if multiple rows are returned) will occur.

You might also like