PL/SQL stands for Procedural Language / Structured Query Language which is extension of SQL.
PL/SQL offers set of procedural commands/statements ,organized in blocks. Hence called block-structured language.
Oracle uses PL/SQL engine to process PL/SQL statements.
Simple PL/SQL block:
PL/SQL block consists of 3 sections.
1.Declaration section. (Optional)
Keywords DECLARE
2.Executable section . (Must)
Keywords BEGIN, END
3.Exception Handling section (Good to have)
Keywords EXCEPTION
Here is simple PL/SQL block that displays a message.
PL/SQL offers set of procedural commands/statements ,organized in blocks. Hence called block-structured language.
Oracle uses PL/SQL engine to process PL/SQL statements.
Simple PL/SQL block:
PL/SQL block consists of 3 sections.
1.Declaration section. (Optional)
Keywords DECLARE
2.Executable section . (Must)
Keywords BEGIN, END
3.Exception Handling section (Good to have)
Keywords EXCEPTION
DECLARE
–- Declare variables,constants
and other code elements
BEGIN
–- Program execution.
Write sql code.
EXCEPTION
-- Exception Handling
END;
Here is simple PL/SQL block that displays a message.
DECLARE
show_message
VARCHAR2 (100) := 'Hello World!';
BEGIN
DBMS_OUTPUT.put_line
(show_message);
EXCEPTION
WHEN OTHERS
THEN DBMS_OUTPUT.put_line (SQLERRM);
END;
No comments:
Post a Comment