Skip to Main Content
  • Questions
  • Managing transacions : Server side or client side

Breadcrumb

Question and Answer

Tom Kyte

Thanks for the question, Totu.

Asked: January 30, 2006 - 4:56 am UTC

Last updated: January 31, 2006 - 4:01 am UTC

Version: 9.2

Viewed 1000+ times

You Asked

Dear Tom.

I am going to develop software look like bank software.

So, which one is better regarding to Managing transaction:
1. Using Packages, procedures at Server side
2. Using ODP.Net's transaction object at Client side. f.e: begintrans, rollback ...


Thanks in advance.




and Tom said...

I have always believed that the client must control the transaction. Only the client knows what constitutes a complete logical unit of work.

I'm assuming a "transaction object" is a fancy way to say "I can issue the transaction control statement COMMIT and ROLLBACK by invoking a method of a connection". If so, it would likely be the thing to use (or just issue "commit", "rollback" in your anonymous block, eg:


begin
procedure1(....);
procedure2(....);
commit;
end;


Understanding that if that statement fails, the database automagically rolls it back for you.

Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

jim, January 30, 2006 - 9:36 pm UTC

Hopefully, he doesn't mean that the client controls the transaction in the sense that the client does the rollback by issuing sql statements to undo the transaction. (eg Siebel does this) vs issinging the rollback statement and having the server do the rollback.

Tom Kyte
January 31, 2006 - 1:59 am UTC

I mean the client issues rollback or commit.

But if you submit a block like:


begin
proc1;
proc2;
commmit;
end;


and either of proc1, proc2 or the commit fails - the transaction is automagically rolled back by the server.

Result

Totu, January 31, 2006 - 3:15 am UTC

Thanks Tom.

So, you advice me to control transaction at client side, no need for "commit" or "rollback" statements at Server side (f.e: inside database procedure).


Another question:
Assume that I have procedure inside database:
proc1:
(emp_id number, newsal number)
update emp set salary = salary + newsal where empid = emp_id;

So, I have following code at client side:

try
Conn.BeginTransaction;
Call proce1(12, 1500);
commit;
except
rollback;
end;

Question: Can proce1 work be managed from transaction that started from client side?

Thanks in advance.



Tom Kyte
January 31, 2006 - 4:01 am UTC

yes, it is just a "statement" as far as we are concerned - and it will be executed atomically (the procedure either succeeds entirely or fails entirely). And the client has the ability to commit the work done by it, or roll it back.

More to Explore

PL/SQL demos

Check out more PL/SQL tutorials on our LiveSQL tool.

PL/SQL docs

PL/SQL reference manual from the Oracle documentation library