Last active
July 26, 2019 20:57
-
-
Save AndyDaSilva52/567b4cecf7a23381213b530279734a91 to your computer and use it in GitHub Desktop.
#Mega #Tributos - Série/Subsérie - Gera INSERT pra incluir todas as numerações entre 1 e 999 para o cadastro de série do Tributos #MegaERP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
SEQ.RESULT SER_ST_CODIGO, 'INSERT INTO MGTRF.TRF_SERIEDOCFIS(ser_st_codigo, ser_st_descricao,ser_st_seriesintegra) ' | |
|| 'SELECT '''|| | |
SEQ.RESULT | |
||''' SER_ST_CODIGO, ''Série '|| LPAD(SEQ.RESULT,3,'0') || ''' SER_ST_DESCRICAO, '''|| SEQ.RESULT ||''' SER_ST_SERIESINTEGRA ' | |
|| 'FROM DUAL WHERE '''|| SEQ.RESULT ||''' NOT IN (SELECT T.SER_ST_CODIGO FROM MGTRF.TRF_SERIEDOCFIS T); COMMIT;' | |
"INS" | |
FROM MGTRF.TRF_SERIEDOCFIS A | |
RIGHT JOIN ( | |
select result from | |
(select rownum result from dual connect by level <= ( | |
999 | |
)) -- MAX | |
where result >= ( | |
1 | |
) -- MIN | |
) SEQ ON TO_CHAR(SEQ.RESULT) = A.SER_ST_CODIGO | |
WHERE A.SER_ST_CODIGO IS NULL | |
; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment