Unable to use transactions with System.Data.OracleClient data provider

I am using VS2008, System.Data.OracleClient, Oracle 10g, and ODAC 10.2.0.20. I haven't been able to get transactions to work. When I use 'connection.BeginTransaction()', the rollback doesn't work. When I use TransactionScope, the output parameter is always DBNull. Any ideas/comments?
Here's the sample code:
// #define ENABLE_TRANSACTION // failure is 'rollback not working'
#define ENABLE_TRANSACTION_SCOPE // failure is 'no output parameter value'
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Data.OracleClient;
#if ENABLE_TRANSACTION_SCOPE
using System.Transactions;
#endif
namespace TestOracleTransaction
class Program
static void Main(string[] args)
#if ENABLE_TRANSACTION_SCOPE
using (TransactionScope scope = new TransactionScope())
#endif
string connectionString = "Data Source=ORADEV;User ID=user;Password=pwd";
using (OracleConnection connection = new OracleConnection(connectionString))
try
connection.Open();
#if ENABLE_TRANSACTION
using (OracleTransaction transaction = connection.BeginTransaction())
#endif
try
#if ENABLE_TRANSACTION_SCOPE
if (Transaction.Current == null)
throw new ArgumentException("no ambient transaction found for OracleClient");
#endif
OracleCommand command = connection.CreateCommand();
#if ENABLE_TRANSACTION
command.Transaction = transaction;
#endif
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "TIS.P_TIS_GATEWAY_INFO_ADD";
OracleParameter param = command.CreateParameter();
param.ParameterName = "p_gateway_id";
param.Direction = ParameterDirection.Input;
param.DbType = DbType.Int64;
param.Value = 18;
command.Parameters.Add(param);
param = command.CreateParameter();
param.ParameterName = "p_info_id";
param.Direction = ParameterDirection.Input;
param.DbType = DbType.Int64;
param.Value = 79;
command.Parameters.Add(param);
param = command.CreateParameter();
param.ParameterName = "p_user";
param.Direction = ParameterDirection.Input;
param.DbType = DbType.String;
param.Value = "spms";
command.Parameters.Add(param);
param = command.CreateParameter();
param.ParameterName = "p_gateway_info_id";
param.Direction = ParameterDirection.Output;
param.DbType = DbType.Int64;
param.Size = sizeof(Int64);
command.Parameters.Add(param);
int count = command.ExecuteNonQuery();
object value = command.Parameters["p_gateway_info_id"].Value;
long id = (value == DBNull.Value) ? -1 : Convert.ToInt64(value);
if (id < 0)
// FAILURE - no output parameter value when TransactionScope enabled
throw new ArgumentException("no return value");
#if ENABLE_TRANSACTION
// FAILURE - rollback doesn't work when Transaction enabled
transaction.Rollback();
#endif
#if ENABLE_TRANSACTION_SCOPE
scope.Complete();
#endif
catch (Exception ex)
System.Console.WriteLine("ERROR: " + ex.Message);
#if ENABLE_TRANSACTION
transaction.Rollback();
#endif
finally
if (connection.State == ConnectionState.Open)
connection.Close();
}

Hi,
First, this is not the place for questions with System.Data.OracleClient, this is the Oracle Data Provider for .NET forum. Having said that I went ahead and tested your code with some slight modifications because you did not provide the stored procedure information. I am assuming your stored procedure is doing some sort of DML since you are using transactions and attempting to commit and rollback.
I tested the following with both Transaction scope and a local transaction object and it worked fine with System.Data.OracleClient. I provided the create table and stored procedure I used.
Observations
========
When using transaction scope, a distributed transactions was executed and the data was inserted and returned in the output variable.
From console
p1 value is Hello World
From SQL Plus
SQL> select * from foo;
C1
Hello World
When using a local transaction, the DML was not inserted when calling rollback and when I changed it to commit, the row was inserted successfully.
Maybe you can test the simple foo example below to see if it works for you. Maybe there is something going on in your SP that is causing your specific observations.
The code I posted at this point is using local transaction and calling transaction.commit(), rollback is commented out. But I tested all scenarios and they worked as expected.
HTH
Jenny
#define ENABLE_TRANSACTION // failure is 'rollback not working'
//#define ENABLE_TRANSACTION_SCOPE // failure is 'no output parameter value'
using System;
using System.Collections.Generic;
using System.Data;
using System.Text;
using System.Data.OracleClient;
#if ENABLE_TRANSACTION_SCOPE
using System.Transactions;
#endif
create table foo (c1 varchar2(50));
create or replace procedure getstr (p1 out varchar2) as
begin
insert into foo(c1) values ('Hello World') returning c1 into p1;
end;
namespace TestOracleTransaction
class Program
static void Main(string[] args)
#if ENABLE_TRANSACTION_SCOPE
using (TransactionScope scope = new TransactionScope())
#endif
string connectionString = "Data Source=orcl;User ID=scott;Password=tiger";
using (OracleConnection connection = new OracleConnection(connectionString))
try
connection.Open();
#if ENABLE_TRANSACTION
using (OracleTransaction transaction = connection.BeginTransaction())
#endif
try
#if ENABLE_TRANSACTION_SCOPE
if (Transaction.Current == null)
throw new ArgumentException("no ambient transaction found for OracleClient");
#endif
OracleCommand command = connection.CreateCommand();
#if ENABLE_TRANSACTION
command.Transaction = transaction;
#endif
command.CommandType = CommandType.StoredProcedure;
command.CommandText = "SCOTT.GETSTR";
OracleParameter param = command.CreateParameter();
param.ParameterName = "p1";
param.Direction = ParameterDirection.Output;
param.DbType = DbType.AnsiString;
param.Size = 20;
command.Parameters.Add(param);
int count = command.ExecuteNonQuery();
object value = command.Parameters["p1"].Value;
Console.WriteLine("p1 value is {0}",value.ToString());
#if ENABLE_TRANSACTION
// FAILURE - rollback doesn't work when Transaction enabled
transaction.Commit();
//transaction.Rollback();
#endif
#if ENABLE_TRANSACTION_SCOPE
scope.Complete();
#endif
catch (Exception ex)
System.Console.WriteLine("ERROR: " + ex.Message);
#if ENABLE_TRANSACTION
transaction.Rollback();
#endif
finally
if (connection.State == ConnectionState.Open)
connection.Close();
}

Similar Messages

  • Unable to use the with clause in oracle 9.0.2

    Hi,
    I need to use oracle SQL with clause in oracle 9.0.2 database. Its a 9i feature but i am unable to use it.
    It is giving internal error, when i try to execute it.
    Even for simple query:
    WITH acct_summary as ( select TOT_COLL_AMT from tdc_acct)
    select TOT_COLL_AMT from acct_summary WHERE TOT_COLL_AMT>100;
    Error message while using 8.0.5 sql plus client:
    SP2-0642: SQL*Plus internal error state 2091, context 0:0:0
    Unsafe to proceed
    Please help to find out why i am not able to use the sql with clause in oracle 9.0.2 database.
    Thanks and regards,
    Raajkathir

    Hi Jens Petersen,
    Yes, You are correct. Thank you very much.
    Regards,
    Raja

  • Using iPhotoToGoogleEarth with manually created gps data

    I use iPhotoToGoogleEarth 2.0 to export photos from iPhoto (version 8.1.2) with automatically created gps-information to GoogleEarth. This works well. If I create the gps location in iPhoto manually, the correct gps data are shown within the information data of the photo. But when I export the photo with iPhotoToGoogleEarth, these gps data are not recognized and the photo cannot be placed to the defined location in GoogleEarth.
    However if I export the photo from iPhoto as a file and import these data to iPhoto again, iPhotoToGoogleEarth will find the correct gps data.
    I assume an error in iPhoto

    When you locate a pic in iPhoto that data is +not written to the file+, instead it's stored in the central database.
    If you then export from iPhoto the data can be written to the file. This is why it's available when you re-import it.
    I think your app is looking in the file for information that is not there. It's looking in the wrong place.
    I assume an error in iPhototoGoogleEarth 2.0
    Regards
    TD

  • Unable to use PE9 with my Canon 5D Mark III

    I could use some help please.  When I try to download my new Canon 5D Mark III Raw into PE9 I get an error message telling me that PE is unable to open it because it is the wrong file type.  My new Canon 5D Mark III lists the file type as ST8Axxxx instead of the normal IMG_xxxx that I'm used to.  Can anyone tell me how to use PE9 with my Canon 5D Mark III camera?  Thank you!

    Hi,
    The 5D MK III is not supported by PSE 9. It requires ACR 6.7 or 7.1 which will not apply to PSE 9.
    You can either :-
    1) Update to a newer version of elements
    2) Use the Canon software to covert the raw files to TIF files and then import the TIF files
    3) Download and install the free Adobe DNG Converter. Convert the raw files to DNG files and then import the DNG files into elements.
    You can obtain latest dng converter from:
    mac: http://www.adobe.com/support/downloads/product.jsp?product=106&platform=Macintosh
    windows: http://www.adobe.com/support/downloads/product.jsp?product=106&platform=Windows
    Hope it helps

  • Creating TO using L_TO_CREATE_DN with SLED or Expiry Date????

    Hi Team,
    I am writing a Ztcode program for the TO creation using function module L_TO_CREATE_DN function module. But my requirement needs VFDAT (Expiry Date ) to be saved for the Trading Order which we create using tcode LT03, Were SLED, Shelf Expiry Date is required during creation with screen.
    Can anybody help how to create TO using FM with expiry date...
    Thanks in adavance, Help is as soon as possible would be grateful.
    Regards,
    Gaurav Patwari
    919967053678
    Edited by: GauravPa on Jun 13, 2011 1:47 PM

    please check the wm status in the inbound delivery, by this error message looks like plant+sloc is not wm managed ?also if possible Please share the screenshot of the putaway tab of delivery

  • Using Spry with large amounts of data

    I was wondering if it is plausible to use spy's Auto suggest
    feature with queries that return around 18,000 rows of data.
    What are the limitations of using spry with this kind of
    overhead?
    My current Situation
    I currently have a cfc that returns a query which is then
    converted to xml using a toXML function and then loaded into spry.
    At this time the xml that is created only contains around 500
    rows but when this is all hooked up to spry's auto suggest feature
    i am experiencing very slow load time.
    What am i doing wrong? My end result would like to be a
    lookup to over 18,000 employees

    in your text box, include an onChange attribute (i think it's
    supported) like this:
    onChange="yourCustomCall(yourformid)"
    Then each time that the text box is changed, a new spry call
    will be made to the server.
    Be warned though: This, like all other AJAX calls, can lead
    to very high server load. each time you make a change in that text
    box, you are making a CF call. Be sure your environment can scale
    to handle that load if it is a high-use site.

  • Leopard : Network : Unable to use DHCP with manual address.

    After installing Leopard on my Macmini (PowerPC 1.42Ghz, 1GB RAM, 80GB HDD), I found my IP address obtains different IP address than Panther and Tiger use. Then I go into System Preferences -> Network -> select Ethernet -> select "Using DHCP with manual address" in the "Configure" combo box, and change the IP address from 192.168.0.8 to 192.168.0.100. Once I hit apply, the network connection never comes back. There is no complaint that another computer is using the 192.168.0.100 IP address. This works if I am using Panther or Tiger on the same computer.
    Any help is appreciated.

    Setting the DHCP to a number you want to use can be very useful in a busy environment. I usually choose to use numbers that are outside of the range of numbers being controlled by my router (Westell).
    Port Forwarding for services like ARD, Azureus, or any server application break when the IP number changes for any reason.
    Some routers will not allow numbers outside of a restricted range of numbers that can be set up in the router configuration menu's. In this case, I find out if the router is assigning numbers from the high or low end and make sure I assign numbers at the opposite end of the range.
    My Westell router does allow me to use numbers other than the range of 50 numbers it has been told to use for DHCP, but I have also encountered problems when trying this on a wireless connection.

  • I'm unable to use Fiverr with Firefox. Last year I was able to order Fiverr gigs and send messages inside Fiverr but for the last 3 weeks I've been unable to.

    I'm unable to use Fiverr.com with Firefox. Last year I was able to order Fiverr gigs and send messages but for the last 3 weeks I've been unable to do either. I can login to Fiverr but I'm unable to use the service.
    I'm using Windows 7.

    Many site issues can be caused by corrupt cookies or cache. In order to try to fix these problems, the first step is to clear both cookies and the cache.
    Note: ''This will temporarily log you out of all sites you're logged in to.''
    To clear cache and cookies do the following:
    #Go to Firefox > History > Clear recent history or (if no Firefox button is shown) go to Tools > Clear recent history.
    #Under "Time range to clear", select "Everything".
    #Now, click the arrow next to Details to toggle the Details list active.
    #From the details list, check ''Cache'' and ''Cookies'' and uncheck everything else.
    #Now click the ''Clear now'' button.
    Further information can be found in the [[Clear your cache, history and other personal information in Firefox]] article.
    Did this fix your problems? Please report back to us!

  • Can I post GL Transactions with past net due date?

    Hi to all,
    Good day!
    My concern is regarding uploading and posting of GL transactions to SAP.
    Is it possible to post a document (GL Transactions) if the net due date is in the past? I am trying to upload and post GL Transactions but the batch input log register says that there is "No batch input data for screen SAPLKACB 0002".
    Document Date: 04/12/06
    Posting Date: 04/12/06
    Translation Date: 04/12/06
    I run the upload program last 04/28/06.
    What could be the cause of the error?
    Your answer would be highly appreciated.
    Thank you very much.
    April

    Hi Dave,
    Thanks you for the reply I really appreciate it.
    I tried to run again the upload program this morning and it was successful. There are no more errors. I simply follow your advise to run it in foreground.
    Thanks so much..
    P.S.
    I can't see any radio button for assigning of points. I want to reward you for your help, how?
    Regards,
    April
    Message was edited by: April
    Message was edited by: April

  • Unable to use HD with usb shows errors on disc,

    I have just bought a new airport extreme, and have conected it to my windows pc using a Belkin draft n adaptor, i am unable to use my 305gb maxtor 3200 0344, which is displayed in the setup utility as the above, but when i open the utility it tells me there are errors on the disc and to connect to my pc and run a disc repair, i have done this and there seems to be no problems, The airport disc agent does'nt seem to display it and is just blank, it is ntfs and on the box it said it is also apple mac compatable, any thoughts, thanx.

    jask, Welcome to the discussion area!
    Sorry but NTFS is not a supported format. You will need to reformat the drive. See KB 305038, AirPort Extreme (802.11n): USB storage device supported formats and protocols.

  • Unable to use SSO with universe connection on top of SAP BW query

    Hi,
    We're creating a universe on top of a SAP BW query by using universe designer.
    We logon to universe designer by using SAP credential.
    When creating the connection, we set the option "Use Single Sign On when refreshing reports at view time" in order to logon to BW server. But when clicking next, an error arises:
    "DBD: Unable to connect to SAP BW server Incomplete logon data"
    The strange thing on this is that there is one laptop which is able to set up this kind of connection, while all other workstations are not able to set it because they recieve that error (we all work against the same BO server). So this looks like an installation issue.
    We reinstalled SAP Integration Solutions on those workstations, but problem is still the same.
    I found thread: Universe Connection Authentication on SAP BW which talks about the same issue, but solution involves uninstalling Xcelsius. But we do need Xcelsius!
    Any suggestions?
    Thanks,
    David.

    >
    Ingo Hilgefort wrote:
    > Hi,
    >
    > - how did you enter the SAP credentials when logging on ?
    username/password with sap authentication
    >
    > - are you using a application server or a message server for the connection ?
    Application server
    >
    > - SAP GUI is installed ?
    SAP GUI 710 patch 11
    >
    > - SAP Integration Kit is installed ? is it a full keycode or a temp keycode ?
    SAP Integration Solutions with temp keycode
    >
    >
    > thanks
    > Ingo

  • How to use nvl with to_char on varchar data type

    Hi,
    I have the datatype as varchar in which i enter date format with timestamp.
    I am using the quey
    select nvl(:p_date,pei_attribute8) from per_people_extra_info .
    Now i need to trucate in date format as Mar,12,2011.
    I tried using
    select tochar(nvl(:p_date,pei_attribute8),'yyyymmmdd') from per_people_extra_info and getting invalid character.
    How to get the output in 'Month ddTH, YYYY' format ????
    Edited by: user12952202 on Oct 27, 2011 12:11 AM

    This will not apply for HR tables..
    I used fnd_date.canonical_to_date function and solved the issue.
    Thanks Again :)
    Edited by: user12952202 on Oct 27, 2011 2:28 AM
    Edited by: user12952202 on Oct 27, 2011 2:28 AM

  • Imesh has taken over your browser I am unable to remove it with system restore or add and remove programmes Help!

    Your browser is preceded by something calling itself imesh it takes pride of place in your browser slot or window whatever you call it.
    As I have said I can't rid myself of it via system restore or in the add & remove programmes part of my X P version of windows.
    It's still there when I re-downloaded Firefox it's planted itself within my other browsers as well, Safari, Chrome and I think it's got into Internet Explorer too.'''bold text'''

    Sheesh. That looks hard. I think it will fall over at this point:
    "Connect to my Exchange mailbox using HTTP" 'cos Thunderbird uses only the regular email protocols: POP, IMAP and SMTP.
    Here (at work) we have in the past have had IMAP and SMTP enabled on our Exchange server so Thunderbird could then connect just like to any other regular internet-based service.
    With the change here to outlook365/outlook 2010 I've had to switch to using DavMail which lets Thunderbird talk to the mail server using OWA.
    I haven't (seriously) tried Exquilla. Whilst I have great respect for its author and some of his other add-ons, I saw no reason to use an add-on that required payment when DavMail works for free.

  • Unable to use camera with MBP in cradle?

    Happy New Year,
    Posting this for my Dad, who finally saw the light and dove headfirst into the world of Mac: appears he is having trouble getting the camera on his 24" ACD to operate when connected to his cradled MBP. We're trying to use Skype or iChat AV, and though he can see me, I can't see him. Audio works fine, and we confirmed the mic on the ACD is being used when the USB is plugged in.
    To isolate the problem, I had him disconnect his MBP USB cable from the display to operate the MBP as a stand alone laptop. We disconnected, he woke up his laptop after he opened it, I called him back, and voila- I was able to see and hear him fine on the MBP (green light is lit). He can also successfully see himself in PhotoBooth using either the laptop alone or with the ACD, so no problem there.
    I read through a related post (http://discussions.apple.com/thread.jspa?messageID=10425681&#10425681) and two embedded Apple Support articles on the use of the camera, but before we pull the ol' SMC reset I want to make SURE I haven't overlooked something obvious. I know it shouldn't be this hard!
    Thanks,
    Eric

    Thanks- answers to your questions in order:
    -Not a dock, and no other piece of hardware involved- he just sets the laptop beneath the ACD in a small, plastic shelf;
    -Good question. While on Skype with him, I was wearing headphones. The sound was quite rich and clear while we were talking with his MBP closed and hooked up to his ACD. Upon disconnect from his MBP I noticed that the sound had changed quite dramatically- more tinny and muffled. Then, when I asked him to reconnect the USB cable to his MBP I discovered quite loudly that the built-in mic is nearby, what with all the sudden noise coming from his fumbling with the cable.
    -I confirmed with him that the lid is down on the MBP. He is running Apple Bluetooth keyboard and mouse.
    Most interesting to me: when the MBP is hooked up to the ACD the Skype preferences page states that the camera is "unable to be accessed or is in use". Yet he is able to open up Photo Booth and take his own picture from the ACD camera. Hmmmm.

  • Unable to use USPS with Safari 7.0.1 or Mavericks

    Hi, Today I tried printing a label with postage at the USPS website. I was unable to proceed off the first page even though all my account info is present. Anybody else have this problem? I'm using Safari 7.0.1 and Mavericks 10.9.1. Website says I must use IE 8. When did that happen!

    Solved my own problem. You now have to enter a package value in order to proceed with Click N Ship

Maybe you are looking for