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.

  • 相关阅读:
    python3 str.encode bytes.decode
    GTX 1080显卡出错
    Android studio2.2 app:transformNative_libsWithStripDebugSymbolForDebug
    psmisc
    How to configure locales to Unicode in a Docker Ubuntu 14.04 container?
    keras中文文档笔记1——概述
    keras中的一些小tips(一)
    基于Theano的深度学习(Deep Learning)框架Keras学习随笔-01-FAQ
    Android studio 更新android SDK
    groovy基础
  • 原文地址:https://www.cnblogs.com/pandora2050/p/12848829.html
Copyright © 2011-2022 走看看