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 ');