DB2 Version 9.7 for Linux, UNIX, and Windows

UNIQUE_SESSION_NAME function - Return a unique session name

The UNIQUE_SESSION_NAME function returns a unique name for the current session.

You can use this function to create a pipe that has the same name as the current session. To create this pipe, pass the value returned by the UNIQUE_SESSION_NAME function to the SEND_MESSAGE procedure as the pipe name. An implicit pipe is created that has the same name as the current session.

Syntax

Read syntax diagramSkip visual syntax diagram
>>-DBMS_PIPE.UNIQUE_SESSION_NAME-------------------------------><

Return value

This function returns a value of type VARCHAR(128) that represents the unique name for the current session.

Authorization

EXECUTE privilege on the DBMS_PIPE module.

Example

Create a pipe that has the same name as the current session.

SET SERVEROUTPUT ON@ 

CREATE PROCEDURE proc1()
BEGIN
  DECLARE    status          INTEGER;
  DECLARE    v_session       VARCHAR(30);
  SET v_session = DBMS_PIPE.UNIQUE_SESSION_NAME;
  SET status = DBMS_PIPE.PACK_MESSAGE('message1');
  SET status = DBMS_PIPE.SEND_MESSAGE(v_session);
  CALL DBMS_OUTPUT.PUT_LINE('Sent message on pipe ' || v_session);
END@

CALL proc1@

This example results in the following output:

Sent message on pipe *LOCAL.myschema.080522010048