Pular para o conteúdo
  • Este tópico contém 1 resposta, 2 vozes e foi atualizado pela última vez 17 anos, 4 meses atrás por Ricardo Portilho Proni.
Visualizando 2 posts - 1 até 2 (de 2 do total)
  • Autor
    Posts
  • #83495
    Avatar photoLeonardo Litz
    Participante

      Olá, alguém sabe como funciona o dbms_alert?

      Desde já agradesço….

      #83500
      Ricardo Portilho Proni
      Participante

        Serve para trocar mensagens entre processos, disparados por alguma ocorrência.
        O EM us este pacote.

        Nunca usei, mas vi este exemplo na internet:

        /* alert.sql */
        set serveroutput on;
        declare
        message varchar2(200);
        status integer;
        begin
        dbms_alert.register(‘my_alert’);
        dbms_alert.waitone(‘my_alert’,message,status,60);
        dbms_output.put_line(‘status = ‘||status);
        dbms_output.put_line(‘message = ‘||message);
        dbms_alert.remove(‘my_alert’);
        end;
        /
        exit;

        /* alert2.sql */
        exec dbms_alert.signal(‘my_alert’,’a message from another process’);
        commit;
        exit;

        REM – alert.cmd (Windows NT/2000)
        start cmd /k sqlplus system/manager @alert
        start system/manager @alert2

        #!/bin/sh

        (for UNIX)

        sqlplus system/manager @alert &
        sqlplus system/manager @alert2

        You can query information about alerts from the SYS.DBMS_ALERT_INFO table. The NAME column is the name of the alert, and SID is the session ID of the session that registered the alert. CHANGED is Y if an alert has been signaled and committed. MESSAGE is the last message passed by the signaler (multiple signals will overwrite each other’s messages). There is one record in this table for each registered event. For example:

        SQL> exec dbms_alert.register(‘my_alert’);
        /* NAME: MY_ALERT
        SID: 00070142001
        CHANGED: N
        MESSAGE:
        */

        SQL> exec dbms_alert.signal(‘my_alert’,’foo’);
        /* NAME: MY_ALERT
        SID: 00070142001
        CHANGED: Y
        MESSAGE: foo
        */

        SQL> exec dbms_alert.signal(‘my_alert’,’foo2′);
        /* NAME: MY_ALERT
        SID: 00070142001
        CHANGED: Y
        MESSAGE: foo2
        */

        SQL> exec dbms_alert.remove(‘my_alert’);
        no rows selected

      Visualizando 2 posts - 1 até 2 (de 2 do total)
      • Você deve fazer login para responder a este tópico.