Friday, January 13, 2017

PLSQL syllabus

                                                          PLSQL Syllabus 




Oracle PL/SQL
Basics of PL/SQL
PL/SQL architecture
PL/SQL and SQL*Plus
PL/SQL Basics
Variables
Constants
Datatypes
Error messages ? user_errors and show errors
PL/SQL wrapper utility
PL/SQL structures
Simple blocks
Control structures
PL/SQL records
Recognizing the Basic PL/SQL Block and Its Sections
Describing the Significance of Variables in PL/SQL
Distinguishing Between PL/SQL and Non-PL/SQL Variables
Declaring Variables and Constants
Executing a PL/SQL Block
Error checking ? exception handling
Defining exceptions
Using the when others clause
Ensuring complete error checking
Passing error messages to calling routine
Boolean logic in PL/SQL
Identifying the Uses and Types of Control Structures
Constructing an IF Statement
Constructing and Identifying Different Loop Statements
Controlling Block Flow Using Nested Loops and Labels
Using Logic Tables
If-then-else structure
Testing for numbers characters and Booleans
Cursors in PL/SQL
Cursor basics
Using a cursor for a multi-row SQL query
Iteration in PL/SQL
For loop
While loop
PL/SQL tables
Defining PL/SQL tables
Reasons to use PL/SQL tables
Populating a PL/SQL table
Retrieving from a PL/SQL table
Dynamic SQL in PL/SQL
Introduction to the dbms_sql package
Creating a dynamic SQL statement
Nested blocks in PL/SQL
Creating nested blocks
Understanding scope in nested blocks
Triggers in PL/SQL
Triggers and database events
Defining a trigger
Timing a trigger
Enabling and disabling a trigger
Stored procedures, functions and packages
Basics of stored procedures
Basics of functions
Basics of packages
Defining stored procedures & functions
Function and stored procedures prototypes
Passing arguments to functions and stored procedures
Recompiling functions and stored procedures
Package forward declaration
Package dependency
Package overloading
Listing package information
Bulking in PL/SQL
Bulk queriesv
Bulk DML (for all statement)
Using cursor attributes
Analyzing impact of bilk operations Database with MySQL

Basic Syntax

PL/SQL is a block-structured language, meaning that PL/SQL programs are divided and written in logical blocks of code. Each block consists of three sub-parts:

S.N. Sections & Description
1 Declarations

This section starts with the keyword DECLARE. It is an optional section and defines all variables, cursors, subprograms, and other elements to be used in the program.

2 Executable Commands

This section is enclosed between the keywords BEGIN and END and it is a mandatory section. It consists of the executable PL/SQL statements of the program. It should have at least one executable line of code, which may be just a NULL command to indicate that nothing should be executed.

3 Exception Handling

This section starts with the keyword EXCEPTION. This section is again optional and contains exception(s) that handle errors in the program.

Every PL/SQL statement ends with a semicolon (;). PL/SQL blocks can be nested within other PL/SQL blocks using BEGIN and END. Here is the basic structure of a PL/SQL block:

DECLARE
   <declarations section>
BEGIN
   <executable command(s)>
EXCEPTION
   <exception handling>
END;
The 'Hello World' Example:
DECLARE
   message  varchar2(20):= 'Hello, World!';
BEGIN
   dbms_output.put_line(message);
END;
/
The end; line signals the end of the PL/SQL block. To run the code from SQL command line, you may need to type / at the beginning of the first blank line after the last line of the code. When the above code is executed at SQL prompt, it produces the following result:

Hello World

PL/SQL procedure successfully completed.
The PL/SQL Identifiers
PL/SQL identifiers are constants, variables, exceptions, procedures, cursors, and reserved words. The identifiers consist of a letter optionally followed by more letters, numerals, dollar signs, underscores, and number signs and should not exceed 30 characters.

By default, identifiers are not case-sensitive. So you can use integer or INTEGER to represent a numeric value. You cannot use a reserved keyword as an identifier.

The PL/SQL Delimiters
A delimiter is a symbol with a special meaning. Following is the list of delimiters in PL/SQL:

Delimiter Description
+, -, *, / Addition, subtraction/negation, multiplication, division
% Attribute indicator
' Character string delimiter
. Component selector
(,) Expression or list delimiter
: Host variable indicator
, Item separator
" Quoted identifier delimiter
= Relational operator
@ Remote access indicator
; Statement terminator
:= Assignment operator
=> Association operator
|| Concatenation operator
** Exponentiation operator
<<, >> Label delimiter (begin and end)
/*, */ Multi-line comment delimiter (begin and end)
-- Single-line comment indicator
.. Range operator
<, >, <=, >= Relational operators
<>, '=, ~=, ^= Different versions of NOT EQUAL

The PL/SQL Comments
Program comments are explanatory statements that you can include in the PL/SQL code that you write and helps anyone reading its source code. All programming languages allow for some form of comments.

The PL/SQL supports single-line and multi-line comments. All characters available inside any comment are ignored by PL/SQL compiler. The PL/SQL single-line comments start with the delimiter -- (double hyphen) and multi-line comments are enclosed by /* and */.

DECLARE
   -- variable declaration
   message  varchar2(20):= 'Hello, World!';
BEGIN
   /*
    *  PL/SQL executable statement(s)
    */
   dbms_output.put_line(message);
END;
/
When the above code is executed at SQL prompt, it produces the following result:

Hello World

PL/SQL procedure successfully completed.
PL/SQL Program Units
A PL/SQL unit is any one of the following:

PL/SQL block

Function

Package

Package body

Procedure

Trigger

Type

Type body

Each of these units will be discussed in the forthcoming chapters.