The DBMS_PIPE package provides a way for sessions in the same database instance to communicate with each other. One of the most useful aspects of Oracle pipes is that pipe communication is asynchronous: you need not COMMIT a transaction in order to initiate pipe-related activity, as is necessary with the DBMS_ALERT package. You can send a message through and receive a message from a pipe at any time. Indeed, more than one session can read or write to the same pipe.
With PL/SQL Release 2.2 only, the CREATE_PIPE function allows you to explicitly request the creation of a pipe, either public or private. The specification is:
FUNCTION DBMS_PIPE.CREATE_PIPE (pipename IN VARCHAR2, maxpipesize IN INTEGER DEFAULT 8192, private IN BOOLEAN DEFAULT TRUE) RETURN INTEGER;
The function returns a numeric status code. If it returns 0, then the pipe was created successfully.
The NEXT_ITEM_TYPE function returns the type of the next item in the local message buffer. Data is put in the message buffer with both the PACK_MESSAGE and the RECEIVE_MESSAGE procedures. Use NEXT_ITEM_TYPE to decide which kind of variable you should use to receive the data from the buffer with the overloaded UNPACK_MESSAGE module. The specification is:
FUNCTION DBMS_PIPE.NEXT_ITEM_TYPE RETURN INTEGER;
where the return value for the function is one of the following:
No more items in buffer
PROCEDURE DBMS_PIPE.PACK_MESSAGE (item IN VARCHAR2); PROCEDURE DBMS_PIPE.PACK_MESSAGE (item IN NUMBER); PROCEDURE DBMS_PIPE.PACK_MESSAGE (item IN DATE);
PROCEDURE DBMS_PIPE.PURGE (pipename IN VARCHAR2);
The RECEIVE_MESSAGE function receives a message from the named pipe and copies the contents of that message to the local message buffer. Once you receive the message into the buffer, you can use the UNPACK_MESSAGE procedure to extract the items from the buffer into local variables. The specification is:
FUNCTION DBMS_PIPE.RECEIVE_MESSAGE (pipename IN VARCHAR2, timeout IN INTEGER DEFAULT MAXWAIT) RETURN INTEGER;
The function returns a status, which will be one of the following INTEGER values:
Successful receipt of message
Timed out waiting to receive a message
Record in pipe too big for buffer; this should never happen
Receipt of message was interrupted
The REMOVE_PIPE function removes a pipe from shared memory. This function must be called to remove a pipe created explicitly with CREATE_PIPE. If your pipe is created implicitly, then it will be removed with a call to PURGE or whenever the pipe is emptied. The specification is:
FUNCTION DBMS_PIPE.REMOVE_PIPE (pipename IN VARCHAR2) RETURN INTEGER;
FUNCTION DBMS_PIPE.SEND_MESSAGE (pipename IN VARCHAR2, timeout IN INTEGER DEFAULT MAXWAIT, maxpipesize IN INTEGER DEFAULT 8192) RETURN INTEGER;
The function returns a status code as follows:
Successful receipt of message
Timed out waiting to send a message
Sending of message was interrupted
The UNIQUE_SESSION_NAME function returns a name that is unique among the sessions currently connected to the database. You can use this function to obtain a name for a pipe that you know will not be in use by any other sessions. The specification is:
FUNCTION DBMS_PIPE.UNIQUE_SESSION_NAME RETURN VARCHAR2;
Copyright (c) 2000 O'Reilly & Associates. All rights reserved.
|This HTML Help has been published using the chm2web software.