zoukankan      html  css  js  c++  java
  • 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.

  • 相关阅读:
    Markdown基本语法
    面向对象
    LeetCode739 每日温度
    LeetCode155 最小栈
    LeetCode279 完全平方数
    LeetCode752 打开转盘锁
    LeetCode622 设计循环队列
    LeetCode200 岛屿的个数
    LeetCode61 旋转链表
    LeetCode138 复制带随机指针的链表
  • 原文地址:https://www.cnblogs.com/pandora2050/p/12848829.html
Copyright © 2011-2022 走看看