How to Work With SELECT Statement in PL/SQL
In this article I am going to explain how to work with SELECT statement in PL/SQL.
Introduction
PL/SQL is define as procedure language/structure query language. PL/SQL is developed by oracle. PL/SQL supports many feature like variables, loops, conditions and exceptions. It also support the concept of array. In present time PL/SQL is integrated component of oracle software. SQL provide limited support for advance programming and PL/SQL fill this gap.
Block is a basic unit of a PL/SQL application. This block is collection of PL/SQL statements grouped as logical unit. Using PL/SQL blocks you can create five different type of program units.
- Stored Function
- Stored procedure
- Anonymous Block
- Trigger
- Package
SELECT Statement in PL/SQL
SELECT statement in PL/SQL is used to insert values in other variables from values stored in table. We use SELECT statement with INTO clause. We place the INTO clause between the select list and PL/SQL clause.
Example
DECLARE
avg_marks marks_info.s_marks%type;
BEGIN
dbms_output.enable;
SELECT avg(s_marks) into avg_marks from marks_info;
dbms_output.put_line('average marks of all student :=' || to_char(avg_marks,'999.99'));
end;
|
Output