View Single Post

   
  #3 (permalink)  
Old 03-06-2008, 02:04 PM
Knut Stolze
 
Posts: n/a
Default Re: Transaction labeling

Prakash wrote:

> Hello
>
> We are using DB2 server V9.5 for our migration project on HP-UX IA64
> platform.
> My question is:
>
> Can we do labeling to a particular transaction?. If so how can we do
> that?.
> Basically we want to give label to transaction , so that use this
> label in other logic.
>
> Please let me know whether transaction labeling feature is available
> or not?


Generally, if you need a transaction identifier, you have a problem in your
code and a broken design. Period.

However, you could do something like the following to generate a unique
identifier for each transaction.

DROP PROCEDURE getTransactionId@
DROP TABLE session.transaction_id@

CREATE PROCEDURE getTransactionId (
OUT transactionId CHAR(13) FOR BIT DATA )
LANGUAGE SQL
BEGIN
DECLARE CONTINUE HANDLER FOR SQLSTATE '42710' BEGIN END;
DECLARE GLOBAL TEMPORARY TABLE session.transaction_id (
id CHAR(13) FOR BIT DATA NOT NULL )
ON COMMIT DELETE ROWS NOT LOGGED ON ROLLBACK DELETE ROWS;
SET transactionId = ( SELECT id
FROM session.transaction_id );
IF transactionId IS NULL THEN
SET transactionId = GENERATE_UNIQUE();
INSERT INTO session.transaction_id
VALUES ( transactionId );
END IF;
END@

--
Knut Stolze
DB2 z/OS Utilities Development
IBM Germany
Reply With Quote