Monday 8 July 2013

Package Body & How to Run it..


Package is the bundle of the related PL/SQL programming elements.


It also include all kind of variables ,their declaration and  the procedure and functions.
Once written, and get the package compile, then stored in an Oracle database permanently and its contents can be shared by many applications. (Definition of Stroed Produre comes into the picture.)

It's acts like an interface between Application and the Database. as shown in the below fig.

 


For creating a Package we are using the Statement CREATE PACKAGE PACKAGE _NAME

We can execute th epackage body via the tolls named as SQL*PLUS and Package Editor.

The Syntex of the PackageBody be:


CREATE or REPLACE PACKAGE BODY <Package Name>
{is,as}
PROCEDURE [Schema..] <ProcedureName>
	(<argument> {IN,OUT,IN OUT} <Data Type>,..)
{IS, AS}
<variable> declarations;
<constant> declarations;

BEGIN
<PL/SQL subprogram body>

EXCEPTION
<PL/SQL Exception block>

END;
 
 
 FUNCTION [Schema..] <FunctionName>(<argument> IN <Data Type>,..)
	return <Data Type> {IS,AS}
	<variable> declarations;
	<constant> declarations;

BEGIN
	<PL/SQL subprogram body>

EXCEPTION
	<PL/SQL Exception block>

END;

END;
/



How to call a function or procedure within a package.

THE SYNTEX BE: call packgename.function_name("parameter");

How to execute a function within a package.

execute packagename.functionname ;

To alter the package :

ALTER package packagename compile body;

Package DROP:

DROP package packagename;











for more information reagarding the package and PL / SQL 

http://www.way2tutorial.com/plsql/plsql_alter_packages.php 

http://www.tutorialspoint.com/plsql/plsql_packages.htm 

 
http://www.razorsql.com/docs/create_package.html 

No comments:

Post a Comment