I have a basic dll which contains common database methods such as getconnectionstring,executescalar, executenonquery,doselect etc. I am working with (vb.net or c#) and oracle. Now i need to write a method for a transaction where i may have 2-3 sqls and should commit only if all of them work. I am trying to see how to do it. I need sql1 to return some sort of unique field which would be used to insert into sql2 and/or sql3.
private sub executeTransaction(byval sql1 as string,byval sql2 as string,byval sql3 as string)
code to begin transaction
execute sql1 returning unique id to a local field 'since this id may be different based on sql, how to handle this?
execute sql2
execute sql3 optional
if exception rollback
commit on finally block and then close the connection object
end sub
I am looking for suggestions/best practices to write the above method. Thanks in advance.