Procedure, Function, Trigger
Procedure, Function, Trigger
PROCEDURE
Procedure
• Procedure is a group of SQL statements which can be
executed repeatedly.
• It is very useful as it reduces the need for rewriting SQL
queries.
Output:
Procedure created.
Executing Stored Procedure
You can call procedure in two ways-
OUTPUT:
Enter value for x: 10
Enter value for y: 20
Sum of two nos= 30
PL/SQL procedure successfully created.
Deleting Stored Procedure
• DROP is used to delete Procedure.
Syntax:
DROP PROCEDURE procedure_name;
Ex:
DROP PROCEDURE greetings;
PL/SQL Function
OUTPUT –
Function Created.
Executing Function
BEGIN
dbms_output.put_line(‘Result is: ' || sum(50,90));
END;
/
OUTPUT –
Result is: 140
PL/SQL function successfully completed.
OUTPUT : Function created.
Deleting a Function
• DROP is used to delete function.
Syntax:
DROP FUNCTION function_name;
Ex:
DROP FUNCTION sum;
PL/SQL Trigger
• Triggers are stored programs, which are automatically executed or
fired when some event occurs.
• Trigger is invoked by Oracle engine automatically whenever a
specified event occurs. Trigger is stored into database and invoked
repeatedly, when specific condition match.
Syntax:
DROP TRIGGER trigger_name;
Ex:
DROP TRIGGER abc;
The End !