Dbms_pipe (pipeline usage)

Source: Internet
Author: User

1. Create a pipeline in another session

 

Set serveroutput on;
Declare
V_statpipe1 integer;
V_statpipe2 integer;
V_pubchar varchar2 (100): = 'this is a text string ';
V_pubdate Date: = sysdate;
V_pubnum number: = 109;

Begin
V_statpipe1: = dbms_pipe.create_pipe ('myprivateip ');

If v_statpipe1 = 0 then
Dbms_pipe.pack_message ('privateine1 ');
Dbms_pipe.pack_message ('privateine2 ');
V_statpipe1: = dbms_pipe.send_message ('myprivatepip ');
End if;

Dbms_pipe.pack_message (v_pubchar );
Dbms_pipe.pack_message (v_pubdate );
Dbms_pipe.pack_message (v_pubnum );
-- Pub Pipe
V_statpipe2: = dbms_pipe.send_message ('mypublicpipe ');
Dbms_output.put_line ('the status of your private pipe is '| v_statpipe1 );
Dbms_output.put_line ('the status of your public pipe is '| v_statpipe2 );
End;
/

2. receive messages in the pipeline in another session.

 

Set serveroutput on;
Declare
V_statpipe1 integer;
V_statpipe2 integer;
V_holdtype integer;
V_holdchar varchar2 (100 );
V_holddate date;
V_holdnum number;
Begin
V_statpipe1: = dbms_pipe.receive_message ('myprivatepipe ', 15 );
Dbms_pipe.unpack_message (v_holdchar );
Dbms_output.put_line (v_holdchar );
Dbms_pipe.unpack_message (v_holdchar );
Dbms_output.put_line (v_holdchar );

-- Public Pipe
V_statpipe2: = dbms_pipe.receive_message ('mypublicpipe', 10 );
Loop
V_holdtype: = dbms_pipe.next_item_type;
If v_holdtype = 0 Then exit;
Elsif v_holdtype = 6 then dbms_pipe.unpack_message (v_holdnum );
Elsif v_holdtype = 9 then dbms_pipe.unpack_message (v_holdchar );
Elsif v_holdtype = 12 then dbms_pipe.unpack_message (v_holddate );
End if;
End loop;

Dbms_output.put_line (v_holddate | ''| v_holdnum |'' | v_holdchar );
End;
/

Another function related to pipe is remove_pipe ();

Status: = dbms_pipe.remove_pipe ('myprivatepip ');
Status: = dbms_pipe.remove_pipe ('mypublicpipe ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.