Have PL/SQL Outputs in Real Time

前端 未结 6 1871
陌清茗
陌清茗 2021-01-03 02:37

Is it possible to have Outputs from PL/SQL in real time? I have a pretty huge package that runs for more than an hour and I\'d like to see where the package is at a particul

6条回答
  •  南笙
    南笙 (楼主)
    2021-01-03 02:48

    Use DBMS_PIPE to write a message to a named pipe. In another session you can read the messages from the pipe. Very simple, works like a charm !

    procedure sendmessage(p_pipename varchar2
                            ,p_message  varchar2) is
          s number(15);
       begin
          begin
             sys.dbms_pipe.pack_message(p_message);
          exception
             when others then
                sys.dbms_pipe.reset_buffer;
          end;
    
          s := sys.dbms_pipe.send_message(p_pipename, 0);
    
          if s = 1
          then
             sys.dbms_pipe.purge(p_pipename);
          end if;
       end;
    
    
    
    
    function receivemessage(p_pipename varchar2
                              ,p_timeout  integer) return varchar2 is
          n   number(15);
          chr varchar2(200);
       begin
          n := sys.dbms_pipe.receive_message(p_pipename, p_timeout);
    
          if n = 1
          then
             return null;
          end if;
    
          sys.dbms_pipe.unpack_message(chr);
          return(chr);
       end;
    

提交回复
热议问题