expsigladb.Package.CLESERCIZIO_BODY.sql Maven / Gradle / Ivy
--------------------------------------------------------
-- DDL for Package Body CLESERCIZIO
--------------------------------------------------------
CREATE OR REPLACE PACKAGE BODY "CLESERCIZIO" AS
procedure UpdRegStatoTrg(aNomeTab varchar2, aNomeTrg varchar2, aStato char, aUser varchar2 ) as
lStrSql varchar2(100);
lTipoTrg char(1);
lOwner varchar2(30);
begin
select user into lOwner from dual;
lTipoTrg := substr(aNomeTrg,2,1) ;
if lTipoTrg = 'D' then
if aStato ='D' then
update LOG_REGISTRY
set STATO_TRG_AD = aStato,
DT_DISATTIVAZIONE_AD = sysdate,
DUVA = sysdate,
UTUV = aUser,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aNomeTab ;
else
update LOG_REGISTRY
set STATO_TRG_AD = aStato,
DT_ATTIVAZIONE_AD = sysdate,
DUVA = sysdate,
UTUV = aUser,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aNomeTab;
end if;
end if;
if lTipoTrg = 'I' then
if aStato ='D' then
update LOG_REGISTRY
set STATO_TRG_AI = aStato,
DT_DISATTIVAZIONE_AI = sysdate,
DUVA = sysdate,
UTUV = aUser ,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aNomeTab;
else
update LOG_REGISTRY
set STATO_TRG_AI = aStato,
DT_ATTIVAZIONE_AI = sysdate,
DUVA = sysdate,
UTUV = aUser ,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aNomeTab;
end if;
end if;
if lTipoTrg = 'U' then
if aStato ='D' then
update LOG_REGISTRY
set STATO_TRG_AU = aStato,
DT_DISATTIVAZIONE_AU = sysdate,
DUVA = sysdate,
UTUV = aUser ,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aNomeTab;
else
update LOG_REGISTRY
set STATO_TRG_AU = aStato,
DT_ATTIVAZIONE_AU = sysdate,
DUVA = sysdate,
UTUV = aUser ,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aNomeTab;
end if;
end if;
end;
procedure attivaTrg(aNomeTab varchar2, aNomeTrg varchar2, aUser varchar2 ) as
lStrSql varchar2(100);
begin
lStrSql := 'ALTER TRIGGER ' || aNomeTrg || ' ENABLE';
execute immediate lStrSql;
CLESERCIZIO.UpdRegStatoTrg(aNomeTab, aNomeTrg, 'A', aUser );
end;
procedure disattivaTrg(aNomeTab varchar2, aNomeTrg varchar2, aUser varchar2 ) as
lStrSql varchar2(100);
begin
lStrSql := 'ALTER TRIGGER ' || aNomeTrg || ' DISABLE';
execute immediate lStrSql;
CLESERCIZIO.UpdRegStatoTrg(aNomeTab, aNomeTrg, 'D', aUser );
end;
procedure INSERTRIGA(aTbName varchar2, aL_ESERCIZIO L_ESERCIZIO%rowtype) is
lUser varchar2(20);
lLogRegistry LOG_REGISTRY%rowtype;
begin
select user into lUser from dual;
select * into lLogRegistry from LOG_REGISTRY
where nome_table_src = aTbName;
if lLogRegistry.NUM_MAX_RIGHE_TABLE_LOG >= aL_ESERCIZIO.PG_STORICO_ then
insert into L_ESERCIZIO(
PG_STORICO_,
CD_CDS,
ESERCIZIO,
DS_ESERCIZIO,
ST_APERTURA_CHIUSURA,
DACR,
UTCR,
DUVA,
UTUV,
PG_VER_REC,
IM_CASSA_INIZIALE,
USER_ ,
DT_TRANSACTION_,
ACTION_
) VALUES (
aL_ESERCIZIO.PG_STORICO_,
aL_ESERCIZIO.CD_CDS,
aL_ESERCIZIO.ESERCIZIO,
aL_ESERCIZIO.DS_ESERCIZIO,
aL_ESERCIZIO.ST_APERTURA_CHIUSURA,
aL_ESERCIZIO.DACR,
aL_ESERCIZIO.UTCR,
aL_ESERCIZIO.DUVA,
aL_ESERCIZIO.UTUV,
aL_ESERCIZIO.PG_VER_REC,
aL_ESERCIZIO.IM_CASSA_INIZIALE,
aL_ESERCIZIO.USER_ ,
aL_ESERCIZIO.DT_TRANSACTION_,
aL_ESERCIZIO.ACTION_
);
else
null;
end if;
end;
procedure updateRegistry(aTbName varchar2, aTipoTrg char, aUser varchar2 ) as
begin
if aTipoTrg = 'D' then
update LOG_REGISTRY
set STATO_TRG_AD = 'A',
DT_ULTIMO_START_AD = sysdate,
NUM_RIGHE_IN_TABLE_LOG = nvl(NUM_RIGHE_IN_TABLE_LOG,0) + 1,
DUVA = sysdate,
UTUV = aUser,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aTbName ;
end if;
if aTipoTrg = 'I' then
update LOG_REGISTRY
set STATO_TRG_AI = 'A',
DT_ULTIMO_START_AI = sysdate,
NUM_RIGHE_IN_TABLE_LOG = nvl(NUM_RIGHE_IN_TABLE_LOG,0) + 1,
DUVA = sysdate,
UTUV = aUser ,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aTbName;
end if;
if aTipoTrg = 'U' then
update LOG_REGISTRY
set STATO_TRG_AU = 'A',
DT_ULTIMO_START_AU = sysdate,
NUM_RIGHE_IN_TABLE_LOG = nvl(NUM_RIGHE_IN_TABLE_LOG,0) + 1,
DUVA = sysdate,
UTUV = aUser ,
PG_VER_REC = PG_VER_REC + 1
where nome_table_src = aTbName;
end if;
end;
end;
© 2015 - 2024 Weber Informatics LLC | Privacy Policy