You are on page 1of 2

Packages : It is a logical grouping of all the related functions and procedures together...

Steps to work with Packages : --> Create the Package Specification... where the Package specification is used for providing the prototypes of all the functions and procedures to be used in the package.. SYNTAX : create package <package_name> --gobal variable declaration(s) is function function_name( arg_info ) return <datatype>; . . procedure procedure_name( arg_info ); . . end; * Create the Package Body... : It is used for providing the definitions for all the prototypes declared in the package specification... Package: create or replace package mycalc is function addnum( a number, b number ) return number; function subnum( a number, b number ) return number; procedure dispnum( a number, b number, res number ); end; Package Body: create or replace package body mycalc is function addnum( a number,b number ) return number is begin return a+b; end addnum; function subnum( a number, b number ) return number is begin return a-b; end subnum; procedure dispnum( a number, b number, res number ) is begin dbms_output.put_line( 'The result of ' || a || ' and ' || b || ' = ' || res ); end dispnum; end;

To execute the members present in the package... --> package_name.member_name(arg_list); where the member can be a function, procedure or a variable... --> Select mycalc.addnum( 10,20 ) from dual; declare a number := &a; b number := &b; res number; begin res := mycalc.addnum( a,b ); mycalc.dispnum( a,b,res ); end; ---------------------------------------------------------------------------------------------

You might also like