• Oracle dbms_pipe打破loop循环


    有用的死循环:

      通过管道传递信息打破循环,涉及两个同用户登录的sqlplus窗体,一个执行循环,另一个用来打破循环:

    循环体:receive_message

    --在SQL*PLUS 中声名一个变量
    variable message varchar2(20);
    
    create or replace procedure receive_message(pipename in varchar2,message out varchar2)
    is
        l_num pls_integer := 0;
        flag pls_integer;
    begin
        loop
            l_num := l_num + 1;
            if l_num > 10 then
                l_num := 0;
            end if;
            dbms_lock.sleep(3);
            dbms_output.put_line(l_num || 'Hello World!');
            if dbms_pipe.receive_message(pipename,0) = 0 then
                dbms_pipe.unpack_message(message);
                exit when message = 'stop';
            end if;
        end loop;    
        flag := dbms_pipe.remove_pipe(pipename);
    end receive_message;

    传递信息的过程:send_message

    create or replace procedure send_message(pipename in varchar2,message in varchar2)
    is
        flag pls_integer;
    begin
        flag := dbms_pipe.create_pipe(pipename);
        if flag = 0 then
            dbms_pipe.pack_message(message);
            flag := dbms_pipe.send_message(pipename);
        end if;
    end send_message;
    

    Syntax

    dbms_pipe.create_pipe(

      pipename    in varchar2,

      maxpipesize   in integer default 8192,

         private        in boolean default true)

    return integer

    This function explicitly create a public or private pipe.If the private flag is TRUE, then the pipe creator is assigned as the owner of the private pipe. Explicitly-created pipes can only be removed by calling remove_pipe, or by shutting down the instance.

  • 相关阅读:
    Centos下安装Redis
    Web框架的本质
    DOM Event
    HTML DOM
    JavaScript运算符
    JavaScript基础
    开发中常用的插件与框架
    selector模块
    IO模型(阻塞、非阻塞、多路复用与异步)
    事件驱动模型
  • 原文地址:https://www.cnblogs.com/pandora2050/p/12848829.html
Copyright © 2020-2023  润新知