CREATE OR replace PROCEDURE DASHBOARD_FIN_SALDO_CONTAS (
    P_DTSALDO IN DATE DEFAULT SYSDATE
) AS

BEGIN

DELETE FROM PDCSALDO;

FOR C_SALDO IN (
    SELECT
        *
    FROM
        (
            SELECT
                CC.NRORG,
                BC.CDBANCO,
                BC.NMBANCO,
                BC.CDPICTCONT,
                BC.CDPICTAGEN,
                CC.CDCONTCORR,
                CC.DSCONTCORR,
                EM.CDEMPRESA,
                EM.NMEMPRESA,
                CC.CDREDUCONT,
                CC.VRLIMITCREDCCOR,
                AG.CDAGENCIA,
                AG.NMAGENCIA,
                '' AS CDCONTCORRMASK,
                '' AS CDAGENCIAMASK,
                NVL(SALDO_CONTACORR(CC.CDREDUCONT,P_DTSALDO),0) AS VRSALDO,
                NVL(SALDO_CONTACORR(CC.CDREDUCONT,P_DTSALDO),0) AS VRSALDOCLIM,
                TO_CHAR(P_DTSALDO,'DD/MM/YYYY')  DTSALDO
            FROM
                CONTCORR CC,
                BANCO BC,
                EMPRESA EM,
                AGENCIA AG
            WHERE
                ( BC.CDBANCO = AG.CDBANCO )
                AND ( AG.CDBANCO = CC.CDBANCO )
                AND ( CC.CDAGENCIA = AG.CDAGENCIA )
                AND ( CC.CDEMPRESA = EM.CDEMPRESA )
            ORDER BY
                CC.CDEMPRESA,
                CC.CDBANCO,
                CC.CDREDUCONT
        )
    WHERE
        VRSALDO <> '0'
    ORDER BY
        VRSALDO DESC
) LOOP
   
   INSERT
    INTO PDCSALDO(
        NRORG,
        CDBANCO,
        NMBANCO,
        CDPICTCONT,
        CDPICTAGEN,
        CDCONTCORR,
        DSCONTCORR,
        CDEMPRESA,
        NMEMPRESA,
        CDREDUCONT,
        VRLIMITCREDCCOR,
        CDAGENCIA,
        NMAGENCIA,
        CDCONTCORRMASK,
        CDAGENCIAMASK,
        VRSALDO,
        VRSALDOCLIM,
        DTSALDO
    )
VALUES
    ( C_SALDO.NRORG, C_SALDO.CDBANCO, C_SALDO.NMBANCO, C_SALDO.CDPICTCONT, C_SALDO.CDPICTAGEN, C_SALDO.CDCONTCORR, 
        C_SALDO.DSCONTCORR, C_SALDO.CDEMPRESA, C_SALDO.NMEMPRESA, C_SALDO.CDREDUCONT, C_SALDO.VRLIMITCREDCCOR, 
        C_SALDO.CDAGENCIA, C_SALDO.NMAGENCIA, C_SALDO.CDCONTCORRMASK, C_SALDO.CDAGENCIAMASK, C_SALDO.VRSALDO,
        C_SALDO.VRSALDOCLIM, C_SALDO.DTSALDO);
        
    END LOOP;

END;
/
create or replace PROCEDURE DASHBOARD_FIN_TITULOS_REC AS
BEGIN
    DELETE FROM PDCTITRECEBER;

    FOR BOLETO_REC IN (
        SELECT
            BR.NRORG,
            TO_CHAR(BR.DTVENBOLREC,'DD/MM/YYYY') DTVENBOLREC,
            CL.NRINSJURCLIE,
            CL.NMRAZSOCCLIE,
            BR.NRPARCBOLREC,
            BR.IDSTATBREC,
            BR.VRBOLREC,
            BR.VRFINALBREC,
            BR.CDEMPRESA,
            E.NMEMPRESA,
            BR.CDFILIAL,
            BR.NRLANBOLREC,
            CL.CDCLIENTE
        FROM
            BOLETRECEBER BR,
            CLIENTE CL,
            EMPRESA E
        WHERE
            BR.CDCLIENTE = CL.CDCLIENTE
            AND BR.IDSTATBREC <> 'B'
            AND BR.CDEMPRESA = E.CDEMPRESA
        ORDER BY
            BR.DTVENBOLREC ASC,
            CL.NMRAZSOCCLIE,
            BR.NRPARCBOLREC DESC
    ) LOOP
        INSERT INTO PDCTITRECEBER (
            NRORG,
            CDEMPRESA,
            CDFILIAL,
            DTVENBOLREC,
            NRPARCBOLREC,
            NRLANBOLREC,
            IDSTATBREC,
            VRBOLREC,
            VRFINALBREC,
            CDCLIENTE,
            NMRAZSOCCLIE,
            NRINSJURCLIE,
            NMEMPRESA
        ) VALUES (
            BOLETO_REC.NRORG,
            BOLETO_REC.CDEMPRESA,
            BOLETO_REC.CDFILIAL,
            BOLETO_REC.DTVENBOLREC,
            BOLETO_REC.NRPARCBOLREC,
            BOLETO_REC.NRLANBOLREC,
            BOLETO_REC.IDSTATBREC,
            BOLETO_REC.VRBOLREC,
            BOLETO_REC.VRFINALBREC,
            BOLETO_REC.CDCLIENTE,
            BOLETO_REC.NMRAZSOCCLIE,
            BOLETO_REC.NRINSJURCLIE,
            BOLETO_REC.NMEMPRESA
        );

    END LOOP;

END;
/
CREATE OR REPLACE PROCEDURE DASHBOARD_FIN_TITULOS_PAG AS
BEGIN
    DELETE FROM PCDTITPAGAR;

    FOR BOLET_PAG IN (
        SELECT
            BP.NRORG,
            TO_CHAR(BP.DTVENBOLPAG,'DD/MM/YYYY') DTVENBOLPAG,
            FO.NRINSJURFORN,
            FO.NMRAZSOCFORN,
            BP.NRPARCBOLPAG,
            BP.IDSTATBPAG,
            BP.VRBOLPAG,
            BP.VRFINALBPAG,
            BP.CDEMPRESA,
            E.NMEMPRESA,
            BP.CDFILIAL,
            BP.NRLANBOLPAG,
            FO.CDFORNECED
        FROM
            BOLETPAGAR BP,
            FORNECEDOR FO,
            EMPRESA E
        WHERE
            BP.CDFORNECED = FO.CDFORNECED
            AND BP.IDSTATBPAG <> 'B'
            AND BP.CDEMPRESA = E.CDEMPRESA
        ORDER BY
            BP.DTVENBOLPAG ASC,
            FO.NMRAZSOCFORN,
            BP.NRPARCBOLPAG DESC
    ) LOOP
    
        INSERT INTO PCDTITPAGAR (
            NRORG,
            DTVENBOLPAG,
            NRINSJURFORN,
            NMRAZSOCFORN,
            NRPARCBOLPAG,
            IDSTATBPAG,
            VRBOLPAG,
            VRFINALBPAG,
            CDEMPRESA,
            NMEMPRESA,
            CDFILIAL,
            NRLANBOLPAG,
            CDFORNECED
        ) VALUES (
            BOLET_PAG.NRORG,
            BOLET_PAG.DTVENBOLPAG,
            BOLET_PAG.NRINSJURFORN,
            BOLET_PAG.NMRAZSOCFORN,
            BOLET_PAG.NRPARCBOLPAG,
            BOLET_PAG.IDSTATBPAG,
            BOLET_PAG.VRBOLPAG,
            BOLET_PAG.VRFINALBPAG,
            BOLET_PAG.CDEMPRESA,
            BOLET_PAG.NMEMPRESA,
            BOLET_PAG.CDFILIAL,
            BOLET_PAG.NRLANBOLPAG,
            BOLET_PAG.CDFORNECED
        );

    END LOOP;

END;
/
create or replace PROCEDURE DASHBOARD_FIN_DIVISAO_RECEITAS AS
BEGIN
    DELETE FROM PDCDIVISAOREC;

    FOR RECEITAS IN (
        SELECT
            CR.NRORG,
            CR.CDEMPRESA,
            CR.CDTPCTRECEB,
            TR.DSTPCTRECEB,
            BR.DTVENBOLREC,
            CR.VRATUAREC
        FROM
            BOLETRECEBER BR,
            CONTARECEBER CR,
            TIPOCTRECEBER TR
        WHERE
            BR.CDFILIAL = CR.CDFILIBOLREC
            AND BR.NRLANBOLREC = CR.NRLANBOLREC
            AND CR.CDTPCTRECEB = TR.CDTPCTRECEB
        ORDER BY
            CR.VRATUAREC DESC
    ) LOOP
        INSERT INTO PDCDIVISAOREC (
            NRORG,
            CDEMPRESA,
            CDTPCTRECEB,
            DSTPCTRECEB,
            DTVENBOLREC,
            VRATUAREC
        ) VALUES (
            RECEITAS.NRORG,
            RECEITAS.CDEMPRESA,
            RECEITAS.CDTPCTRECEB,
            RECEITAS.DSTPCTRECEB,
            RECEITAS.DTVENBOLREC,
            RECEITAS.VRATUAREC
        );

    END LOOP;

END;
/
create or replace PROCEDURE DASHBOARD_FIN_DIVISAO_DESPESAS AS
BEGIN
    DELETE FROM PDCDIVISAOPAG;

    FOR DESPESAS IN (
        SELECT
            CP.NRORG,
            CP.CDEMPRESA,
            CP.CDTPCTPAGAR,
            TR.DSTPCTPAGAR,
            BR.DTVENBOLPAG,
            CP.VRATUAPAG
        FROM
            BOLETPAGAR BR,
            CONTAPAGAR CP,
            TIPOCTPAGAR TR
        WHERE
            BR.CDFILIAL = CP.CDFILIBPAG
            AND BR.NRLANBOLPAG = CP.NRLANBOLPAG
            AND CP.CDTPCTPAGAR = TR.CDTPCTPAGAR
        ORDER BY
            VRATUAPAG DESC
    ) LOOP
        INSERT INTO PDCDIVISAOPAG (
            NRORG,
            CDEMPRESA,
            CDTPCTPAGAR,
            DSTPCTPAGAR,
            DTVENBOLPAG,
            VRATUAPAG
        ) VALUES (
            DESPESAS.NRORG,
            DESPESAS.CDEMPRESA,
            DESPESAS.CDTPCTPAGAR,
            DESPESAS.DSTPCTPAGAR,
            DESPESAS.DTVENBOLPAG,
            DESPESAS.VRATUAPAG
        );

    END LOOP;

END;
/
CREATE OR REPLACE PROCEDURE DASHBOARD_FIN_CLI_INAD AS
BEGIN
    DELETE FROM PDCCLIEINADIPLE;

    FOR CLIENTES IN (
        SELECT
            CL.NRORG,
            BR.CDEMPRESA,
            E.NMEMPRESA,
            CL.NRINSJURCLIE,
            CL.NMRAZSOCCLIE,
            BR.DTVENBOLREC,
            MIN(TO_CHAR(BR.DTVENBOLREC,'DD/MM/YYYY') ) AS DTVENBOLRECMIN,
            MAX(TO_CHAR(BR.DTVENBOLREC,'DD/MM/YYYY') ) AS DTVENBOLRECMAX,
            SUM(BR.VRFINALBREC) VRTOTALBOLREC
        FROM
            BOLETRECEBER BR,
            CLIENTE CL,
            EMPRESA E
        WHERE
            BR.CDCLIENTE = CL.CDCLIENTE
            AND BR.DTVENBOLREC < ( SYSDATE - 1 )
            AND BR.IDSTATBREC <> 'B'
            AND BR.CDEMPRESA = E.CDEMPRESA
        GROUP BY
            CL.NRORG,
            BR.CDEMPRESA,
            E.NMEMPRESA,
            CL.NRINSJURCLIE,
            CL.NMRAZSOCCLIE,
            BR.DTVENBOLREC
        ORDER BY
            VRTOTALBOLREC DESC
    ) LOOP
        INSERT INTO PDCCLIEINADIPLE (
            NRORG,
            CDEMPRESA,
            NMEMPRESA,
            NRINSJURCLIE,
            NMRAZSOCCLIE,
            DTVENBOLREC,
            DTVENBOLRECMIN,
            DTVENBOLRECMAX,
            VRTOTALBOLREC
        ) VALUES (
            CLIENTES.NRORG,
            CLIENTES.CDEMPRESA,
            CLIENTES.NMEMPRESA,
            CLIENTES.NRINSJURCLIE,
            CLIENTES.NMRAZSOCCLIE,
            CLIENTES.DTVENBOLREC,
            CLIENTES.DTVENBOLRECMIN,
            CLIENTES.DTVENBOLRECMAX,
            CLIENTES.VRTOTALBOLREC
        );

    END LOOP;

END;
/
CREATE OR REPLACE PROCEDURE DASHBOARD_FIN_COUNT AS
BEGIN
    DELETE FROM FINPDCCONT;

    FOR COUNT_FIN IN (
        SELECT
            IDFINPDCCONT,
            NRORG,
            CDEMPRESA,
            COUNT(*) NRCOUNT
        FROM
            (
                SELECT
                    'VENCIDO_REC' IDFINPDCCONT,
                    NRORG,
                    CDEMPRESA
                FROM
                    BOLETRECEBER BR
                WHERE
                    TRUNC(BR.DTVENBOLREC) < TRUNC(SYSDATE)
                    AND BR.IDSTATBREC IN (
                        'A',
                        'E'
                    )
                UNION ALL
                SELECT
                    'ABERTO_DIA_REC' IDFINPDCCONT,
                    NRORG,
                    CDEMPRESA
                FROM
                    BOLETRECEBER BR
                WHERE
                    TRUNC(BR.DTVENBOLREC) = TRUNC(SYSDATE)
                    AND BR.IDSTATBREC = 'A'
                UNION ALL
                SELECT
                    'VENCIDO_PAG' IDFINPDCCONT,
                    NRORG,
                    CDEMPRESA
                FROM
                    BOLETPAGAR BR
                WHERE
                    TRUNC(BR.DTVENBOLPAG) < TRUNC(SYSDATE)
                    AND BR.IDSTATBPAG IN (
                        'A',
                        'E'
                    )
                UNION ALL
                SELECT
                    'ABERTO_DIA_PAG' IDFINPDCCONT,
                    NRORG,
                    CDEMPRESA
                FROM
                    BOLETPAGAR BR
                WHERE
                    TRUNC(BR.DTVENBOLPAG) = TRUNC(SYSDATE)
                    AND BR.IDSTATBPAG = 'A'
                UNION ALL
                SELECT
                    'BAIXADO_REC' IDFINPDCCONT,
                    BA.NRORG,
                    BA.CDEMPRESA
                FROM
                    BOLETRECEBER BR,
                    BAIXARECEBIDA BA
                WHERE
                    BR.IDSTATBREC = 'B'
                    AND BR.NRORG = BA.NRORG
                    AND BR.CDEMPRESA = BA.CDEMPRESA
                    AND BR.NRBAIXAREC = BA.NRBAIXAREC
                    AND ( ( TRUNC(BR.DTVENBOLREC) < TRUNC(SYSDATE) )
                          OR ( TRUNC(BR.DTVENBOLREC) = TRUNC(SYSDATE) ) )
                    AND TRUNC(BA.DTBAIXAREC) = TRUNC(SYSDATE)
                UNION ALL
                SELECT
                    'BAIXADO_PAG' IDFINPDCCONT,
                    BA.NRORG,
                    BA.CDEMPRESA
                FROM
                    BOLETPAGAR BR,
                    BAIXAPAGA BA
                WHERE
                    BR.IDSTATBPAG = 'B'
                    AND BR.NRORG = BR.NRORG
                    AND BR.CDEMPRESA = BA.CDEMPRESA
                    AND BR.NRBAIXAPAG = BA.NRBAIXAPAG
                    AND ( ( TRUNC(BR.DTVENBOLPAG) < TRUNC(SYSDATE) )
                          OR ( TRUNC(BR.DTVENBOLPAG) = TRUNC(SYSDATE) ) )
                    AND TRUNC(BA.DTBAIXAPAG) = TRUNC(SYSDATE)
            )
        GROUP BY
            IDFINPDCCONT,
            NRORG,
            CDEMPRESA
        ORDER BY
            CDEMPRESA
    ) LOOP
        INSERT INTO FINPDCCONT (
            IDFINPDCCONT,
            NRORG,
            CDEMPRESA,
            NRCOUNT
        ) VALUES (
            COUNT_FIN.IDFINPDCCONT,
            COUNT_FIN.NRORG,
            COUNT_FIN.CDEMPRESA,
            COUNT_FIN.NRCOUNT
        );

    END LOOP;

END;
/
CREATE OR REPLACE PROCEDURE DASHBOARD_FIS_COUNT
    AS
BEGIN
    DELETE FROM FISPDCCONT;

    FOR COUNT_FIS IN (
        SELECT
            NRORG,
            CDEMPRESA,
            DTENTRVENDA AS DTFISPDCCONT,
            'CUPOM_VENDAS' AS IDFISPDCCONT
        FROM
            (
                SELECT DISTINCT
                    V.NRORG,
                    V.CDFILIAL,
                    V.CDEMPRESA,
                    V.DTENTRVENDA,
                    V.IDAPROVACAONFCE,
                    V.CDCAIXA,
                    '' AS CDINSCESTA,
                    DECODE(IDTPEMISVEND,'N','NFC-E','SAT') AS TIPO,
                    DECODE(TU.DTFECHCAIX,NULL,'Aberto','Fechado') AS STATUS
                FROM
                    VENDA V,
                    FILIAL F,
                    PARAVEND PA,
                    TURCAIXA TU
                WHERE
                    V.IDTPEMISVEND IN (
                        'N',
                        'S'
                    )
                    AND V.CDFILIAL = F.CDFILIAL
                    AND V.IDTPAMBNFCE = '1'
                    AND V.IDSTATUSNFCE IN (
                        'A',
                        'C'
                    )
                    AND V.IDSITUVENDA = 'O'
                    AND F.CDEMPRESA = V.CDEMPRESA
                    AND V.IDAPROVACAONFCE IN (
                        'P',
                        'E'
                    )
                    AND V.CDFILIAL = PA.CDFILIAL
                    AND PA.IDPREVALIDCUPOM = 'S'
                    AND TU.CDFILIAL = V.CDFILIAL
                    AND TU.CDCAIXA = V.CDCAIXA
                    AND F.CDFILIAL = PA.CDFILIAL
                    AND TRUNC(TU.DTMOVTURCAIX) = V.DTENTRVENDA
                UNION ALL
                SELECT DISTINCT
                    V.NRORG,
                    V.CDFILIAL,
                    V.CDEMPRESA,
                    V.DTENTRVENDA,
                    V.IDAPROVACAONFCE,
                    V.CDCAIXA,
                    '' AS CDINSCESTA,
                    'REDUÇÃOZ' AS TIPO,
                    DECODE(TU.DTFECHCAIX,NULL,'Aberto','Fechado') AS STATUS
                FROM
                    REDUCAOZ R,
                    VENDA V,
                    FILIAL F,
                    PARAVEND PA,
                    TURCAIXA TU
                WHERE
                    R.DTREDUCAOZ = V.DTENTRVENDA
                    AND R.CDFILIAL = V.CDFILIAL
                    AND R.CDCAIXA = V.CDCAIXA
                    AND (
                        V.IDTPEMISVEND NOT IN (
                            'N',
                            'S'
                        )
                        OR V.IDTPEMISVEND IS NULL
                    )
                    AND IDAPROVACAONFCE IN (
                        'P',
                        'E'
                    )
                    AND V.IDSITUVENDA = 'O'
                    AND F.CDEMPRESA = V.CDEMPRESA
                    AND R.IDSTATUS = 'A'
                    AND V.CDFILIAL = PA.CDFILIAL
                    AND TU.CDFILIAL = V.CDFILIAL
                    AND TU.CDCAIXA = V.CDCAIXA
                    AND F.CDFILIAL = PA.CDFILIAL
                    AND TRUNC(TU.DTMOVTURCAIX) = V.DTENTRVENDA
            )
        UNION ALL
        SELECT
            NRORG,
            CDEMPRESA,
            DATA AS DTFISPDCCONT,
            'NOTA_FISCAL' AS IDFISPDCCONT
        FROM
            (
                SELECT DISTINCT
                    'Pendente' AS IDSTATUS,
                    CDEMPRESA,
                    N.NRORG,
                    NRINSJURNF,
                    DTENTRSAID,
                    DTEMISSAO,
                    NRNOTAFISC,
                    VRNOTAFISC,
                    DECODE(IDENTRSAIDOP,'E',DTENTRSAID,DTEMISSAO) AS DATA,
                    CDINSCESTA,
                    IDTPIJURNF,
                    IDENTRSAIDOP,
                    IDSISTEMA,
                    CDTIPOOPER,
                    '' AS CDIMPOSTO,
                    '' AS SGIMPOSTO,
                    1 AS MOVIMENTO
                FROM
                    NOTAFISCAL N,
                    IMPOSTONF I,
                    IMPOSTO IM,
                    PARAMFISCAL P
                WHERE
                    N.IDSTATUS = 'P'
                    AND N.IDSTATUSNFE <> 'D'
                    AND I.CDIMPOSTO = IM.CDIMPOSTO
                    AND I.CDFILIAL = N.CDFILIAL
                    AND I.NRLANCTONF = N.NRLANCTONF
                UNION ALL
                SELECT DISTINCT
                    DECODE(IDSTATUS,'P','Pendente',DECODE(IDSTATUS,'A','Aprovada','Emitida') ) AS IDSTATUS,
                    CDEMPRESA,
                    N.NRORG,
                    NRINSJURNF,
                    DTENTRSAID,
                    DTEMISSAO,
                    NRNOTAFISC,
                    VRNOTAFISC,
                    DECODE(N.IDENTRSAIDOP,'E',DTENTRSAID,DTEMISSAO) AS DATA,
                    CDINSCESTA,
                    IDTPIJURNF,
                    N.IDENTRSAIDOP,
                    IDSISTEMA,
                    N.CDTIPOOPER,
                    IM.CDIMPOSTO,
                    IM.SGIMPOSTO,
                    1 AS MOVIMENTO
                FROM
                    NOTAFISCAL N,
                    IMPOBRIGTPOPER I,
                    IMPOSTO IM,
                    PARAMFISCAL P
                WHERE
                    N.IDSTATUS <> 'C'
                    AND N.IDSTATUSNFE <> 'D'
                    AND I.CDTIPOOPER = N.CDTIPOOPER
                    AND I.IDENTRSAIDOP = N.IDENTRSAIDOP
                    AND I.CDIMPOSTO = IM.CDIMPOSTO
                    AND NVL(N.IDSISTEMA,'DFS') <> 'REC'
                    AND NVL(N.IDSISTEMA,'DFS') <> 'PAG'
                    AND NVL(N.IDSISTEMA,'DFS') <> 'CMP'
                    AND NVL(N.IDSISTEMA,'DFS') <> 'SUP'
                    AND NVL(N.IDSISTEMA,'DFS') <> 'TMP'
                    AND NVL(N.IDSISTEMA,'DFS') <> 'FIS'
                    AND NOT EXISTS (
                        SELECT
                            IMPOSTONF.CDFILIAL,
                            IMPOSTONF.NRLANCTONF
                        FROM
                            IMPOSTONF
                        WHERE
                            IMPOSTONF.CDFILIAL = N.CDFILIAL
                            AND IMPOSTONF.NRLANCTONF = N.NRLANCTONF
                            AND IMPOSTONF.CDIMPOSTO = I.CDIMPOSTO
                    )
            )
        ORDER BY
            CDEMPRESA
    ) LOOP
        INSERT INTO FISPDCCONT (
            IDFISPDCCONT,
            NRORG,
            CDEMPRESA,
            DTFISPDCCONT
        ) VALUES (
            COUNT_FIS.IDFISPDCCONT,
            COUNT_FIS.NRORG,
            COUNT_FIS.CDEMPRESA,
            COUNT_FIS.DTFISPDCCONT
        );

    END LOOP;

END;
/
create or replace PROCEDURE DASHBOARD_PROCEDURES (
    P_DTFINAL IN DATE DEFAULT SYSDATE
 ) AS

BEGIN

    DASHBOARD_FIN_SALDO_CONTAS(P_DTFINAL);

    DASHBOARD_FIN_TITULOS_REC;

    DASHBOARD_FIN_TITULOS_PAG;

    DASHBOARD_FIN_DIVISAO_RECEITAS;

    DASHBOARD_FIN_DIVISAO_DESPESAS;

    DASHBOARD_FIN_CLI_INAD;

    DASHBOARD_FIN_COUNT;

    DASHBOARD_FIS_COUNT;

END;
/
BEGIN
  DBMS_SCHEDULER.CREATE_JOB (
   job_name           =>  'JOB_DASHBOARD_ERP',
   job_type           =>  'PLSQL_BLOCK',
   job_action         =>  'BEGIN DASHBOARD_PROCEDURES(); END;',
   start_date         =>  SYSDATE,
   repeat_interval    =>  'FREQ=HOURLY;INTERVAL=2',
   end_date           =>   NULL,
   auto_drop          =>   FALSE,
   job_class          =>  'DEFAULT_JOB_CLASS',
   ENABLED            =>   TRUE,
   comments           =>  'JOB PARA DASHBOARD DO ERP');
END;
/

BEGIN
   dbms_scheduler.run_job('JOB_DASHBOARD_ERP');
END;