Professional Documents
Culture Documents
PL/SQL
DBMS L-5
PL/SQL
PL/SQL is a combination of SQL along with the
procedural features of programming languages.
DECLARE
<declarations section>
BEGIN DECLARE
message varchar2(20):= 'Hello, World!’;
<executable command(s)> BEGIN
dbms_output.put_line(message);
EXCEPTION END;
/
<exception handling>
END;
Handling BEGIN
...
EXCEPTION
WHEN <EXCEPTION_NAME1> THEN
Statement1 ;
WHEN <EXCEPTION_NAME2> THEN
Statement2 ;
...
WHEN OTHERS THEN
Default Statement ;
END ;
/
SELECT LAST_NAME,GET_SENIOR_EMPLOYEE(EMPLOYEE_ID)
FROM EMPLOYEES ;
Trigger
{BEFORE | AFTER | INSTEAD OF }
{INSERT [OR] | UPDATE [OR] | DELETE}
[OF col_name]
ON table_name
[REFERENCING OLD AS o NEW AS n]
[FOR EACH ROW]
WHEN (condition)
DECLARE
Declaration-statements
BEGIN
Executable-statements
EXCEPTION
Exception-handling-statements
END;