Tuesday, October 5, 2010

What are the datatypes a available in PL/SQL ?

Following are the datatype supported in oracle PLSQL
Scalar Types
BINARY_INTEGER
DEC
DECIMAL
DOUBLE PRECISION
FLOAT
INT
INTEGER
NATURAL
NATURALN
NUMBER
NUMERIC
PLS_INTEGER
POSITIVE
POSITIVEN
REAL
SIGNTYPE
SMALLINT
CHAR
CHARACTER
LONG
LONG RAW
NCHAR
NVARCHAR2
RAW
ROWID
STRING
UROWID
VARCHAR
VARCHAR2
DATE
INTERVAL DAY TO SECOND
INTERVAL YEAR TO MONTH
TIMESTAMP
TIMESTAMP WITH LOCAL TIME ZONE
TIMESTAMP WITH TIME ZONE

BOOLEAN

Composite Types
RECORD
TABLE
VARRAY
LOB TypesBFILE
BLOB
CLOB
NCLOB

Reference Types
REF CURSOR
REF object_type

What is the basic structure of PL/SQL ?

A PL/SQL block has three parts:
a declarative part
an executable part
and an exception-handling part.
First comes the declarative part in which items can
be declared. Once declared items can be manipulated in the executable part.
Exceptions raised during execution can be dealt with in the exception-handling part.

Programmatic Constructs

 What are the different types of PL/SQL program units that can be defined and stored in ORACLE database?
Procedures, functions, packages and database triggers.

 What is a Procedure?
A Procedure consist of a set of SQL and PL/SQL statements that are grouped together as a unit to solve a Specific problem or perform a set of related tasks.

 What is difference between Procedures and Functions?
A Function returns a value to the caller where as a Procedure does not.

What is a Package?
A Package is a collection of related procedures, functions, variables and other package constructs together as a unit in the database.

What are the advantages of having a Package?
Increased functionality (for example, global package variables can be declared and used by any procedure in the package) and performance (for example all objects of the package are parsed compiled, and loaded into memory once)

 What is Database Trigger?
A Database Trigger is procedure (set of SQL and PL/SQL statements) that is automatically executed as a result of an insert in, update to, or delete from a table.

 What are the uses of Database Trigger?
Database triggers can be used to automatic data generation, audit data modifications, enforce complex Integrity constraints, and customize complex security authorizations.

What are the differences between Database Trigger and Integrity constraints?
A declarative integrity constraint is a statement about the database that is always true. A constraint applies to existing data in the table and any statement that manipulates the table. A trigger does not apply to data loaded before the definition of the trigger; therefore, it does not guarantee all data in a table conforms to the rules established by an associated trigger. A trigger can be used to enforce transitional constraints where as a declarative integrity constraint cannot be used.