Bug 718 - OracleClient on MacOSX: Ref Cursor out parameter
Summary: OracleClient on MacOSX: Ref Cursor out parameter
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Data ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2011-09-10 10:07 UTC by gchompy
Modified: 2011-09-10 20:31 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

The finished OracleParameter.cs file (39.54 KB, application/octet-stream)
2011-09-10 10:07 UTC, gchompy

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report for Bug 718 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description gchompy 2011-09-10 10:07:22 UTC
Created attachment 299 [details]
The finished OracleParameter.cs file

When using Oracle functions/procedures/packages, passing a REF CURSOR as an OUT parameter is an extremely important capability. In Mono 2.10.5, this feature is broken on Mac OS X. Any time the code attempts to specify the OracleType of an OracleParameter object to be OracleType.Cursor, an error is thrown.

To fix this bug I just had to move one line of code, so it should be fairly easy to test and deploy.

I'm looking at source TarBall 2.10.5

If you look at line 1122, you'll see:
Type valType = value.GetType ();

Not sure what this is supposed to be doing, but when 'value' is 'OracleType.Cursor' it throws:
SystemError: Object reference not set to an instance of an object

To fix this, all I did was move this line 1132 so that the use of valType is immediately after.

My final code looks like this:
			case OracleType.LongRaw:
			case OracleType.Raw:
				Type valType = value.GetType ();
				if (valType.FullName == "System.Guid")
					dbType = DbType.Guid;
					dbType = DbType.Binary;
				ociType = OciDataType.Raw;

After recompiling and running 'make install', my ref cursors worked fine.

Please conduct some standard tests and if acceptable, please update the trunk. I'll be proud to develop our application in Mono on Mac and then deploy to our users in Windows!
Comment 1 Miguel de Icaza [MSFT] 2011-09-10 18:42:46 UTC
The error means that "value" would be null, I am not sure that this is a OracleType.Cursor.

Would you mind providing us with a test case that shows the problem?
Comment 2 gchompy 2011-09-10 20:31:53 UTC
I tried adding a test case via the 'Create Test Case' link, but I don't think I've got access.

The best test case is from the Mono Website:    

C# Example 5 - Returning a REF CURSOR from an Oracle stored procedure via an OracleDataReader from an out parameter

Step 1.  Install Oracle Database Server in the usual way. I am using Oracle 11g running on Fedora 13 (on a VM)
Step 2.  Install the Oracle Instant Client for MacOSX. You need to  use the 32 bit client, even though you may have an OS which is 64 bit. Download from the Oracle Website and unzip:
Step 3.  You'll probably need to tweak the connection settings in Test.cs so it points to your Oracle DB. For example:
        string connectionString =
          "User ID=scott;" +
Step 4. Compile the Test.cs into Test.exe
mcs Test.cs /r:System.Data.dll /r:System.Data.OracleClient.dll
Step 5. Set the environment variable to point to where you unzipped the Oracle client.
export DYLD_LIBRARY_PATH=/Users/chompy/Library/Oracle/instantclient_10_2
You may need to clone this file:
cp libclntsh.dylib.10.1 libclntsh.dylib
Step 6. You can now run Test.exe
mono Test.exe