Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Getting different session id when using pragma autonomous_transaction

816802Aug 15 2011 — edited Aug 16 2011
Hi All,

I got a question regarding Pragma Autonomous_Transaction.

When a Pragma Autonomous_Transaction is called, the code using it will be executed totally in a different session.

In that case when I am trying to print the session ids, then I am still getting the same.

Please find the below example.

declare
y varchar2(250);
procedure pr_1 is
pragma autonomous_transaction;
x varchar2(250);
begin
select sys_context('USERENV','SID') into x from dual;
dbms_output.put_line(x);
end pr_1;
begin
pr_1;

select sys_context('USERENV','SID') into y from dual;
dbms_output.put_line(y);

end;
/

OUTPUT
708
708

Request to correct my understanding on Pragma Autonomous_Transaction.

Thanks,
Madhu K.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 13 2011
Added on Aug 15 2011
6 comments
847 views