| 4/7/2006 12:31:54 AM |
I'm starting a new project in Oracle (which I'm very new to) using ORMapper 3.2 (I started using it a while back and we're still using it for other projects).
Everything works perfectly well except calling stored procedures (I'm guessing this is because Oracle requires a cursor output parameter). Is there a way to get this working? Does the new version support SelectProcedures in Oracle? |
| 4/8/2006 12:22:40 AM |
Ok, I found a quick workaround/hack to get it to work for me. I'll post it just there's anybody out there as crazy as I am... :-)
After reading this page that microsoft graciously made: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnadonet/html/msdnorsps.asp
I realized all that needed to be done was to add an output parameter of type OracleType.Cursor. But since the IDataParamater.DbType didn't have that type, and I didn't want to change much code, I changed the code in the 'else parameter.Type is null' portion of Wilson.ORMapper.Internals.Connection.GetParameter(...) to this:
if (dbParameter is System.Data.OracleClient.OracleParameter && dbParameter.Direction == ParameterDirection.Output) { ((System.Data.OracleClient.OracleParameter)dbParameter).OracleType = System.Data.OracleClient.OracleType.Cursor; } else { dbParameter.DbType = DbType.String; }
Basically it implies that if you're using oracle, and setting an ouput parameter of an unknown type, use the OracleType.Cursor. Since setting the cursor is all that's necessary for the DataReader to return results, that's all I needed for it to work (besides adding the parameter to the SelectProcedure to specify the name of the cursor variable, which I do only if I'm using Oracle as the provider). |