Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: remote sessions (database link, v$session)...
IDJ, if I understand what you want it is for session A running on
database A to be able to know what v$session.sid was created on
database B to support the distributed transaction issued from A.
Finding this from a third session on either database is one thing but if you want the information back in session A as definded above then I think you can test the following idea in more detail.
The remote code will have to be a pl/sql code object (procedure, function, package) and will issue a call to dbms_transaction.local_transaction_id. It will then take the transaction id which is really the rollback segment number, slot, and sequence and find it in v$transaction from which a join to v$session can be done. The remote SID could be passed back. A second remote DML statement issued from the same database A session should be part of the same transaction until a commit or rollback is issued.
You will need to test to see if this will work. On local instance. UT1 > select dbms_transaction.local_transaction_id 2 from sys.dual;
LOCAL_TRANSACTION_ID
COUNT(*)
42
LOCAL_TRANSACTION_ID
Now create function on remote db.
drop function tid;
create function tid return varchar2
as
t_id varchar2(18);
begin
select dbms_transaction.local_transaction_id into t_id from sys.dual;
return t_id;
end;
/
TID
ut1 > select count(*) from chassis_no;
COUNT(*)
42
TID
LOCAL_TRANSACTION_ID
HTH -- Mark D Powell -- Received on Thu Dec 15 2005 - 10:55:33 CST