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 (show other bugs)
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2011-09-10 10:07 UTC by gchompy
Modified: 2011-09-10 20:31 UTC (History)
2 users (show)

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


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

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
./mcs/class/System.Data.OracleClient/System.Data.OracleClient/OracleParameter.cs

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;
				else
					dbType = DbType.Binary;
				ociType = OciDataType.Raw;
				break;



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:    
http://www.mono-project.com/Oracle

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:
instantclient-basic-10.2.0.4.0-macosx-x86.zip
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 =
          "Data Source=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.101)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SID=macoracl)));" +
          "User ID=scott;" +
          "Password=tiger;";
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

Note You need to log in before you can comment on or make changes to this bug.