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.

  • 相关阅读:
    找到一种给vs2012对话框插入背景图片不会失真的方法
    第一次用C语言把数据写入文件中
    Java学习路线图
    一:MyBatis Generator 【SpringMvc+Spring+MyBatis+Maven整合学习笔记】
    windows系统安装Redis
    js子级窗口相互调用父级的方法
    MSSQL 发布订阅,实现读写分离
    查看MS SQL最耗时间资源的SQL
    数据库优化
    mybatis与hibernate区别
  • 原文地址:https://www.cnblogs.com/pandora2050/p/12848829.html
Copyright © 2011-2022 走看看