Les - 01-Introduction To PLSQL
Les - 01-Introduction To PLSQL
1-2 Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
Agenda
1-3 Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
About PL/SQL
PL/SQL:
• Stands for “Procedural Language extension to SQL”
• Is Oracle Corporation’s standard data access language for
relational databases
• Seamlessly integrates procedural constructs with SQL
1-4 Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
About PL/SQL
PL/SQL:
• Provides a block structure for executable units of code.
Maintenance of code is made easier with such a well-
defined structure.
• Provides procedural constructs such as:
– Variables, constants, and data types
– Control structures such as conditional statements and loops
– Reusable program units that are written once and executed
many times
1-5 Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
PL/SQL Run-Time Architecture
PL/SQL block
procedural
Procedural statement
executor
PL/SQL
PL/SQL Engine
SQL
Oracle Server
1-6 Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
Benefits of PL/SQL
SQL 1
SQL 2
…
SQL
IF...THEN
SQL
ELSE
SQL
END IF;
SQL
1-7 Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
Benefits of PL/SQL
1-8 Copyright © 2010, Oracle and/or its affiliates. All rights reserved.
PL/SQL Block Structure
• DECLARE (optional)
– Variables, cursors, user-defined exceptions
• BEGIN (mandatory)
– SQL statements
– PL/SQL statements
• EXCEPTION (optional)
– Actions to perform
when exceptions occur
• END; (mandatory)
Database Server
Tools Constructs Constructs
Anonymous blocks Anonymous blocks
Application procedures Stored procedures or
or functions functions
SET SERVEROUTPUT ON
a. True
b. False