PKG_NKW_SDV.SPB
Source Package Body
Padronização de Tipos de Dados.
create or replace package body pkg_nkw_sdv
timestamp '2006-07-07:10:10:10'
is
------------------------------------------------------------------
-- 2006 DataPRO Developers - m@urelio
------------------------------------------------------------------
-- Version: 2.0.2
------------------------------------------------------------------
-- Collections, Records, Variables, Constants, Exceptions, Cursors
------------------------------------------------------------------
gv_sdvc1 constant varchar2(256) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ||
'ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ' ||
'1234567890' ||
'!@#$%&*()'' _"+-=/|\?,[.]{;}<:>';
gv_sdvc2 constant varchar2(256) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ||
'ÁÀÂÃÄÉÈÊËÍÌÎÏÓÒÔÕÖÚÙÛÜÇ' ||
'abcdefghijklmnopqrstuvwxyz' ||
'áàâãäéèêëíìîïóòôõöúùûüç' ||
'1234567890' ||
'~!@#$%^&*()'' _"+-=/|\?,[.]{;}<:>ªº' || chr(10);
gv_sdvc3 constant varchar2(256) := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' ||
'1234567890';
------------------------------------------------------------------
----------------------- Private Section --------------------------
------------------------------------------------------------------
------------------------------------------------------------------
------------------------ Public Section --------------------------
------------------------------------------------------------------
------------------------------------------------------------------
-- IS_SDV
------------------------------------------------------------------
function is_sdv(fv_value in date,
fv_std in varchar2)
return boolean
is
retval boolean := (FALSE);
begin
if (fv_value is not null) then
if (upper(fv_std) = 'D1') then
if (fv_value >= to_date('01/01/0001','dd/mm/yyyy') and
fv_value = trunc(fv_value)) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'D2') then
if (fv_value >= to_date('01/01/0001','dd/mm/yyyy')) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'D3') then
if (fv_value = trunc(fv_value)) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'D4') then
retval := (TRUE);
end if;
else
retval := (TRUE);
end if;
return retval;
exception
when others then raise;
end is_sdv;
------------------------------------------------------------------
function is_sdv(fv_value in number,
fv_std in varchar2)
return boolean
is
retval boolean := (FALSE);
begin
if (fv_value is not null) then
if (upper(fv_std) = 'N1') then
if (fv_value = trunc(fv_value) and fv_value >= 0) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'N2') then
if (fv_value = trunc(fv_value)) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'N3') then
if (fv_value >= 0) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'N4') then
retval := (TRUE);
end if;
else
retval := (TRUE);
end if;
return retval;
exception
when others then raise;
end is_sdv;
------------------------------------------------------------------
function is_sdv(fv_value in varchar2,
fv_std in varchar2)
return boolean
is
retval boolean := (FALSE);
begin
if (fv_value is not null) then
if (upper(fv_std) = 'C1') then
if (nvl(length(replace(translate(fv_value, gv_sdvc1, 'A'),'A','')),0) = 0 and
ltrim(fv_value) = fv_value and rtrim(fv_value) = fv_value) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'C2') then
if (nvl(length(replace(translate(fv_value, gv_sdvc2, 'A'),'A','')),0) = 0) then
retval := (TRUE);
end if;
elsif (upper(fv_std) = 'C3') then
if (nvl(length(replace(translate(fv_value, gv_sdvc3, 'A'),'A','')),0) = 0 and
ltrim(fv_value) = fv_value and rtrim(fv_value) = fv_value and
substr(fv_value,1,1) between 'A' and 'Z') then
retval := (TRUE);
end if;
end if;
else
retval := (TRUE);
end if;
return retval;
exception
when others then raise;
end is_sdv;
end pkg_nkw_sdv;
|