Oracle development articles + dbms_pipe pipeline technology

Description: This article is a guidebook for beginners in PL/SQL development.
Tags: PL/SQL, pipe, pipe, loop, optimization, acceleration, dbms_pipe
Interpretation: DBMS_PIPE pipe package is a function introduced by Oracle11gR1, used in the same routine (example ) To communicate between different sessions.
Advantages: Because the pipe pipeline in PL/SQL has high-performance characteristics, it is often used for data transmission in the loop body. It is
easy to learn: the unnecessary parts are deleted in the text, so that beginners can learn it at a glance Will
Reminder: If you find a problem or a better way to write this article, please leave a message or private message me to modify and optimize


-Create a stored procedure with a pipeline

create or replace  procedure  p_select
is
  i        simple_integer := 1;
  j        simple_integer := 2000000000;
  v        simple_integer := 0;
  message  char(10);
  pipename char(20) := 'pipe_zzt_select';
begin
  for i in 1 .. j loop
    select /*+ no_result_cache */
     count(*) into v
      from zzt.info a, zzt.info b
     where a.sal != b.sal
       and a.id < 100
       and a.sal < 50000;
    if dbms_pipe.receive_message(pipename, 0) = 0 then
      dbms_pipe.unpack_message(message);
      exit when message = 'stop';
    end if;
  end loop;
  v := dbms_pipe.remove_pipe(pipename);
end;
/

--Send stop information to the loop body (pipe_zzt_select)

set timing on
declare
 pipename char(20) :='pipe_zzt_select';
 message  char(10) :='stop';
 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 ;
/

※ If you think the article is well written, don’t forget to give the author a thumbs up at the end of the article~

over

 

 

Guess you like

Origin blog.csdn.net/zzt_2009/article/details/112388622