To create package in SQL for beginners.
About Package
package is the container that contain procedure and functions.
It has two section that is package specification and package body.
-----------------------------------------------------------------------------------------------
Create a Package Name mypack
create or replace package mypack
as
procedure ct_chk(ct in nvarchar2,ctr out number);
procedure nm_chk(name in nvarchar2,ctr out number);
function sal_chk(sal in number) return number;
end mypack;
/
--------------------------------------------------------------------------------------------------
Create a Package Body to check City name
create or replace package body mypack
as
procedure ct_chk(ct in nvarchar2,ctr out number)
is
begin
ctr:=0;
if(lower(ct) not in ('patna','delhi'))then
ctr:=1;
end if;
end;
end mypack;
/