-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path1-remove_sequences.sql
36 lines (32 loc) · 1.29 KB
/
1-remove_sequences.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
--FUNCAO PARA REMOVER SEQUENCES
create or replace function remove_sequence() returns void language 'plpgsql' as
$$
declare
nomeDaSequence pg_class.relname%TYPE;
crSequences CURSOR FOR SELECT c.relname FROM pg_class c WHERE c.relkind = 'S';
begin
OPEN crSequences;
LOOP
FETCH crSequences INTO nomeDaSequence;
EXIT WHEN NOT FOUND;
IF UPPER(nomeDaSequence) <> 'SQ_FIDELIZACAO_NUMERO' AND
UPPER(nomeDaSequence) <> 'SQ_NSU' AND
UPPER(nomeDaSequence) <> 'SQ_NSU_GARANTIA' AND
UPPER(nomeDaSequence) <> 'SQ_NUMERO_CARTAO' AND
UPPER(nomeDaSequence) <> 'SQ_ALIQUOTA_ICMS' AND
UPPER(nomeDaSequence) <> 'ASSISTENTE_COMPRA_ACA_ID_SEQ' AND
UPPER(nomeDaSequence) <> 'ASSISTENTE_COMPRA_ITEM_ACI_ID_SEQ'AND
UPPER(nomeDaSequence) <> 'ASSISTENTE_COMPRA_PERFORMANCE_ACP_ID_SEQ' AND
UPPER(nomeDaSequence) <> 'ESTATISTICA_PENDENTE_EPT_ID_SEQ' AND
UPPER(nomeDaSequence) <> 'ESTATISTICA_PRODUTO_COMPRA_EPC_ID_SEQ' AND
UPPER(nomeDaSequence) <> 'ESTATISTICA_PRODUTO_MOVIMENTACAO_EPM_ID_SEQ' AND
UPPER(nomeDaSequence) <> 'ESTATISTICA_PRODUTO_VENDA_EPV_ID_SEQ'
THEN
execute 'DROP SEQUENCE IF EXISTS ' || UPPER(nomeDaSequence);
ELSE
RAISE NOTICE 'Sequences não será excluída : %', UPPER(nomeDaSequence);
END IF;
END LOOP;
CLOSE crSequences;
end;
$$