fixes bug#0011649
dev: emerson qua: Implementação para garantir a integridade da tabela TARIFA, podendo existir apenas um registro ativo com os seguintes valores: TRAMO_ID, MARCA_ID, CLASESERVICIO_ID, MONEDA_ID, VIGENCIATARIFA_ID, ORGAOCONCEDENTE_ID e RUTA_ID. git-svn-id: http://desenvolvimento.rjconsultores.com.br/repositorio/sco/BD/FlyWay/trunk@83640 d1611594-4594-4d17-8e1d-87c2c4800839master
parent
65f095e8b8
commit
37f4407bd2
|
@ -1,35 +1,19 @@
|
||||||
declare
|
declare
|
||||||
itemExists number;
|
indice_nao_existe exception;
|
||||||
instrucao varchar2(255);
|
pragma exception_init (indece_nao_existe , -01418);
|
||||||
begin
|
begin
|
||||||
itemExists := 0;
|
execute immediate 'DROP INDEX TARIFA_UNICA';
|
||||||
|
exception when indice_nao_existe then null;
|
||||||
select count(constraint_name) into itemExists
|
end;
|
||||||
from all_constraints
|
/
|
||||||
where upper(constraint_name) = upper('TARIFA_UNICA');
|
|
||||||
|
|
||||||
if itemExists > 0 then
|
|
||||||
execute immediate 'ALTER TABLE TARIFA DROP CONSTRAINT TARIFA_UNICA';
|
|
||||||
end if;
|
|
||||||
|
|
||||||
|
|
||||||
select 'DROP INDEX '||OWNER||'.TARIFA_UNICA' into instrucao
|
|
||||||
from all_indexes
|
|
||||||
where upper(index_name) = upper('TARIFA_UNICA');
|
|
||||||
|
|
||||||
if instrucao is not null then
|
|
||||||
execute immediate instrucao;
|
|
||||||
end if;
|
|
||||||
|
|
||||||
end;/
|
|
||||||
|
|
||||||
declare
|
declare
|
||||||
column_exists exception;
|
column_exists exception;
|
||||||
pragma exception_init (column_exists , -00001);
|
pragma exception_init (column_exists , -00001);
|
||||||
begin
|
begin
|
||||||
execute immediate 'CREATE UNIQUE INDEX UNQ_TARIFA ON TARIFA (CASE WHEN ACTIVO = 1 THEN
|
execute immediate 'CREATE UNIQUE INDEX UNQ_TARIFA ON TARIFA (CASE WHEN ACTIVO = 1 THEN
|
||||||
TRAMO_ID || MARCA_ID || CLASESERVICIO_ID || MONEDA_ID || VIGENCIATARIFA_ID || ORGAOCONCEDENTE_ID || RUTA_ID
|
TRAMO_ID || MARCA_ID || CLASESERVICIO_ID || MONEDA_ID || VIGENCIATARIFA_ID || ORGAOCONCEDENTE_ID || RUTA_ID
|
||||||
ELSE NULL END)';
|
ELSE NULL END)';
|
||||||
exception when column_exists then null;
|
exception when column_exists then null;
|
||||||
end;
|
end;
|
||||||
/
|
/
|
Loading…
Reference in New Issue