Lesson 1
Oracle PL/SQL Programming
Welcome to the second course in the Introduction to Oracle Certification Series, Programming in PL/SQL.
As the name implies, this series focuses on preparing you for certification in Oracle.
What is this Series about?
The information covered in this series helps you get started on the Oracle Certified Database Administrator and/or Certified Application Developer paths. Another important goal of this series is to enable you to
- create advanced SQL queries,
- write beginning to intermediate PL/SQL blocks, and
- familiarize you with Oracle's unique SQL extensions.
PL/SQL is an integral part of the Oracle database engine. This course will introduce you to PL/SQL and explain how you can build PL/SQL programming structures. PL stands for Procedural Language.
This language offers procedural techniques to build your SQL (Structured Query Language) commands.
You can use this language to construct procedures, triggers, functions, packages, and more.
Primary PL/SQL constructs a PL/SQL Developer should know
PL/SQL (Procedural Language for SQL) is Oracle Corporation's procedural extension for SQL and the Oracle relational database. PL/SQL is integrated into the Oracle Database (since version 7), and it adds a wide array of procedural features, such as control structures, looping, exception handling, and more, to the powerful SQL database language. For a PL/SQL developer, understanding and effectively using the following primary PL/SQL constructs is crucial:
- Blocks: The fundamental building units of PL/SQL applications are blocks, which can be anonymous or named (procedures, functions, packages, triggers, and so on). A block consists of a declaration section, an execution section, and an exception handling section.
- Variables and Constants: These are used to store temporary data. Variables can change their value throughout the execution, while constants hold the same value once they are initialized.
- Data Types: Understanding various data types (scalar, composite, reference, and LOBs) is crucial for declaring variables and constants effectively.
- Control Structures: These include conditional statements (IF THEN ELSE) and loops (LOOP, WHILE, FOR), which control the flow of execution based on certain conditions.
- Cursors: Cursors are used to process individual rows returned by database queries. Cursors can be implicit or explicit, and understanding how to manage them is key to handling data sets effectively.
- Exception Handling: Exception handling allows a PL/SQL program to catch and process runtime errors or predefined and user-defined exceptions gracefully using the EXCEPTION block.
- Procedures and Functions: These are named PL/SQL blocks that perform a specific task and can be invoked with parameters. Functions return a value, while procedures do not.
- Packages: Packages are groups of related procedures, functions, variables, and other package constructs. They are used to encapsulate and organize related PL/SQL constructs into a single logical unit.
- Triggers: Triggers are procedures that are automatically executed in response to certain events on a particular table or view, such as insertions, updates, or deletions.
- Records: Records are composite data structures that can hold data from multiple fields of different data types, similar to a row in a database table.
- Collections: Collections are single-dimensional arrays that can be indexed by integers or strings (Associative arrays, Nested tables, Varrays).
- Dynamic SQL: It allows for the construction and execution of SQL statements dynamically at runtime, which is useful for writing flexible code.
Understanding and being able to effectively use these constructs allows a PL/SQL developer to write powerful, efficient, and secure database applications. Mastery of these elements is foundational for advanced database programming and application optimization in an Oracle environment.
Course Goals
After completing the course, you will be able to:
- Describe the basic structure of a PL/SQL block
- Create a nested PL/SQL block
- Describe the different PL/SQL and non-PL/SQL variables
- Identify the scope of variables when using nested blocks
- Apply best practices for naming conventions and commenting your code
- Gain an overview of the different PL/SQL datatypes, including composite datatypes such as PL/SQL RECORD and TABLE
- Place identifiers and use literals and operators within a PL/SQL block
- Build logic by using PL/SQL control structures, including loops, labels, and the
GOTO
statement
- Use explicit cursors to process multiple records
- Raise implicit and explicit exceptions
Oracle Database PL/SQL Programming
The bottom line is this:
- Inside PL/SQL programs, the most flexible, and often the best-performing, of the collections is the index-by table.
- Use nested tables when working with nested table data stored in the database. Nested tables are appropriate for large collections that the application typically stores and retrieves a portion of at a time.
- Use VARRAYs when working with VARRAY table data stored in the database. This type of collection is appropriate for small collections that the application stores and retrieves in their entirety.
Learning Technologies
In this course, you will learn and practice PL/SQL skills using diagams, carousels and Slide Shows.
Oracle Series
Programming in PL/SQL is the second of three courses in the introduction to
Oracle Certification Series.
In the next lesson, the
Oracle PL/SQL Course Requirements will be discussed.