Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Look up keyword
Like this
63Activity
0 of .
Results for:
No results containing your search query
P. 1
PL SQL Material

PL SQL Material

Ratings:

4.33

(3)
|Views: 2,980|Likes:
Published by writesmd
Oracle Plsql Material
Oracle Plsql Material

More info:

Published by: writesmd on Jul 16, 2008
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as DOC, PDF, TXT or read online from Scribd
See more
See less

03/11/2013

pdf

text

original

 
PL/SQL
PL/SQL stands for Procedural Language/SQL.PL/SQL extends SQL by adding control Structures found in otherprocedural language.PL/SQL combines the flexibility of SQL with Powerful feature of 3
rd
generation Language.The procedural construct and database access Are present in PL/SQL.PL/SQL can be used in both in databasein Oracle Server and in Client side application development tools.
Advantages of PL/SQL
Support for SQL, support for object-oriented programming,, better performance, portability, higherproductivity, Integration with Oraclea] Supports the declaration and manipulation of object types and collections.b] Allows the calling of external functions and procedures.c] Contains new libraries of built in packages.d] with PL/SQL , an multiple sql statements can be processed in a single command line statement.Oracle Supports PL/SQL version 8.0.4.0.0
PL/SQL Datatypes
Scalar TypesBINARY_INTEGER ,DEC,DECIMAL,DOUBLE ,,PRECISION,FLOAT,INT,INTEGER,NATURAL, NATURALN,NUMBER,NUMERIC, PLS_INTEGER,POSITIVE,POSITIVEN,REAL,SIGNTYPE, SMALLINT,CHAR,CHARACTER,LONG,LONGRAW,NCHAR,NVARCHAR2,RAW,ROWID,STRING, VARCHAR,VARCHAR2, Composite TypesTABLE, VARRAY, RECORDLOB TypesBFILE, BLOB, CLOB, NCLOBReference TypesREF CURSORBOOLEAN, DATEDBMS_OUTPUT.PUT_LINE :It is a pre-defined package that prints the message inside the parenthesis
ATTRIBUTES
Allow us to refer to data types and objects from the database.PL/SQL variables and Constants can haveattributes. The main advantage of using Attributes is even if you Change the data definition, you don’t needto change in the application.
%TYPE 
It is used when declaring variables that refer to the database columns.Using %TYPE to declare variable has two advantages. First, you need not know the exact datatype of variable. Second, if the database definition of variable changes, the datatype of variable changesaccordingly at run time.
%ROWTYPE 
The %ROWTYPE attribute provides a record type that represents a row in a table (or view). The record canstore an entire row of data selected from the table or fetched from a cursor or strongly typed cursorvariable.
1
 
CONTROL STRUCTURES
Conditional Control 
Sequence of statements can be executed based on a certain condition using the if statement.There are threeforms of if statements, namely, if then,if then else and if the Elsif.ITERATIVE CONTROLA sequence of statements can be executed any number of times using loop constructs.Loops can be broadly classified into:
Simple Loops , For Loops , While Loops
Simple Loops
Key Word loop should be placed before the first statement in the sequence and the key word end loop afterthe last statement in the sequence.EXIT : It is a command that comes out of the loop.
While Loop
This statement includes a condition associated with a sequence of statement. If the Condition evaluates totrue, then the sequence of statements will be executed, and again Control resumes at the beginning of theloop else the loop is bypassed and control passes To next statement.
For Loop
The number of iterations for a while loop is unknown until the loop terminates, whereas The number of iterations in a for loop is known before the loop gets executed. The for loop statement specifies a range of integers, to execute the sequence of statements once for each integer.REVERSE: Reverse key word is used to print the values from upper bound to lower bound.
EXCEPTION
An Exception is raised when an error occurs. In case of an error then normal execution stops and the controlis immediately transferred to the exception handling part of the PL/SQL Block.Exceptions are designed for runtime handling, rather than compile time handling. Exceptions improvereadability by letting you isolate error-handling routines.
Types
Pre-defined Exception, User-defined Exception
USER – DEFINED EXCEPTIONS
User – defined exception must be defined and explicitly raised by the user
EXCEPTION_INIT 
A named exception can be associated with a particular oracle error. This can be used to trap the errorspecifically.
PRAGMA EXCEPTION_INIT(exception_name, Oracle_error_number);
The pragma EXCEPTION_INIT associates an exception name with an Oracle,error number. That allows you torefer to any internal exception by name and to write a specific handler
RAISE_APPLICATION_ERROR
The procedure raise_application_error lets you issue user-defined error messages from stored subprograms.That way, you can report errors to your application and avoid returning unhandled exceptions.To call raise_application_error, you use the syntaxraise_application_error(error_number, message[, {TRUE | FALSE}]);
2
 
where error_number is a negative integer in the range -20000 .. -20999 and message is a character stringup to 2048 bytes long.
PRE – DEFINED EXCEPTIONS
3

Activity (63)

You've already reviewed this. Edit your review.
1 hundred reads
1 thousand reads
Dragan liked this
Hari2905 liked this
jayashreeoracle liked this
titun8723 liked this
Nizam Shaik liked this

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->