SQL>
SQL> create or replace procedure proc( cmd in varchar2 )
2 as
3 status number;
4 resp long;
5 answer_pipe varchar2(255) default replace(dbms_pipe.unique_session_name,'$','_');
6 begin
7 dbms_pipe.pack_message( answer_pipe );
8 dbms_pipe.pack_message( cmd );
9
10 status := dbms_pipe.send_message( 'HOST_PIPE' );
11 if ( status <> 0 ) then
12 raise_application_error( -20001, 'Pipe error' );
13 end if;
14
15 status := dbms_pipe.receive_message( answer_pipe );
16 if ( status <> 0 ) then
17 raise_application_error( -20001, 'Pipe error' );
18 end if;
19 dbms_pipe.unpack_message( resp );
20 dbms_output.put_line( substr( resp, 1, 80 ) );
21 end;
22 /