Unit 9 PL & SQL Language
Unit 9 PL & SQL Language
1. IF …THEN…ELSE 2. CASE…
a number;
begin
a:=1;
loop
sum1:=sum1+a;
a:=a+1;
end loop;
DBMS_OUTPUT.PU
T_LINE('sum of 1
to 100 is '||sum1);
end;
View
s A PL/SQL view is a virtual table that contains data from one or
more tables.
This statement first drops the existing view and then creates it again.
sales_employees;
Cursor
s Cursor is a temporary working area created in
the system memory when your SQL statement is
executed.
a
c Execute account_update(‘A001’,’Patel’,125000);
c
o
Store
Function
A function is similar to a procedure, except that it returns a
single value.
Example:
CREATE FUNCTION GetTotalRevenue()
RETURNS DECIMAL(10,2)
BEGIN
RETURN (SELECT SUM(TotalAmount) FROM Orders);
END
Stored Procedure & Store
FunctionFunction Stored Procedure
Returns a single value, either as a table Can return zero, a single value, or
or as a scalar, always. several values.
Run-time compilation and execution The database contains stored
occur for functions. procedures that have been parsed and
compiled.
Only input parameters are permitted. Both input and output parameters are
supported.
Transactions are not permitted within A stored procedure can
a function. contain transactions.
A function cannot call a stored A stored procedure can be called a
procedure. function.
THANK
YOU!!
www.paruluniversi