Calling Oracle Retrieval Stored Procedure

Posts   
 
    
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 12-Apr-2008 07:38:19   

I am calling a stored proc which returns a ref cursor and a string. The string is populated only if there is an error within the stored proc.

When I call the stored proc, I get the following error :invalid operation on null data.

It seems like an error in the generated code.

The following code fragments are all from the generated code :

if((ValueConverter.Convert(parameters[3])!=null) && (ValueConverter.Convert(parameters[3])!=System.DBNull.Value)) {

The definition of Convert method is :

internal class ValueConverter { internal static object Convert(OracleParameter parameter) { object toReturn = parameter.Value;

... case "Oracle.DataAccess.Types.OracleString": toReturn = ((OracleString)parameter.Value).Value; break; ...

If the string parameter is null, above is obviously giving an error because there is no test for null.

I am using LLBLGen Pro 2.5 Final. Self referencing two class template targeted at .NET Framewwork 2.0. Oracle 10g database using ODP.NET 10g v2.

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 12-Apr-2008 23:25:15   

Seems to me that it is related with ODP, please read this similar thread: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=9072

Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 13-Apr-2008 10:22:51   

Thanks for that.

What is described is exactly my problem but I am using LLBGen Pro 2.5 Final version (as opposed to LLBGen Pro 2.0 in the thread you refer to) and so the fix should already be applied to the templates I am using?

Am I missing something here?

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 14-Apr-2008 08:54:57   

What's the exact LLBLGen Pro runtime library version are you using?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 14-Apr-2008 10:55:39   

If it's a crash on the line you posted, you'd get a null reference exception. As you get a different error, it seems not to originate there. At least post the actual exception and stacktrace you got.

Frans Bouma | Lead developer LLBLGen Pro
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 15-Apr-2008 02:44:10   

The error message is :

Oracle.DataAccess.Types.OracleNullValueException was unhandled by user code Message="Invalid operation on null data" Source="Oracle Data Provider for .NET" Number=-2502 StackTrace: at Oracle.DataAccess.Types.OracleString.get_Value() at PPS.DAL.StoredProcedureCallerClasses.ValueConverter.Convert(OracleParameter parameter) in C:\PPS_DAL\StoredProcedureCallerClasses\ActionProcedures.cs:line 568 at PPS.DAL.StoredProcedureCallerClasses.RetrievalProcedures.PpskStudentCallistaPpspGetStudentDetails(Int64 pStudentId, Nullable`1 pAcadYr, String& pErrorMsg) in C:\PPS_DAL\StoredProcedureCallerClasses\RetrievalProcedures.cs:line 149 at StudentInformation.Button1_Click(Object sender, EventArgs e) in d:\Documents and Settings\kkrishna\My Documents\Visual Studio 2005\WebSites\PPS\StudentInformation.aspx.cs:line 41 at System.Web.UI.WebControls.Button.OnClick(EventArgs e) at System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) InnerException:

Stack Trace is :

[External Code] 

PPS.DAL.DLL!PPS.DAL.StoredProcedureCallerClasses.ValueConverter.Convert(Oracle.DataAccess.Client.OracleParameter parameter = {P_ERROR_MSG}) Line 568 + 0x48 bytes C# PPS.DAL.DLL!PPS.DAL.StoredProcedureCallerClasses.RetrievalProcedures.PpskStudentCallistaPpspGetStudentDetails(long pStudentId = 19004044, short? pAcadYr = 2005, ref string pErrorMsg = "") Line 149 + 0x13 bytes C# App_Web_13mxjbw9.dll!StudentInformation.Button1_Click(object sender = {Text = "Display Student Data"}, System.EventArgs e = {System.EventArgs}) Line 41 + 0x2c bytes C# [External Code]

The following information is from the llblgen generated code project : SD.LLBLGen.Pro.DQE.Oracle10g.NET20 Version : 2.5.0.0 Runtime version :v2.0.50727

Oracle.DataAccess Version : 2.102.2.20 Runtime version :v2.0.50727

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 15-Apr-2008 09:57:03   

Very weird, because to be able to test for null, one has to read the parameter's value, but that apparently can't be done because the getter of the parameter returns this exception. What a dumb decision by Oracle (but this isn't the first time in ODP.NET)

I see there's a boolean parameter 'IsNull', which should be checked. I'll correct that in the template.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 15-Apr-2008 10:07:41   

sigh... Oracle's wizards decided it would be great if there was an interface, INullable, which could be used to test any Oracle* parameter for null. Unfortunately, the interface is internal for all but ODP.NET 10gv2. So I can't fix the template with some easy code... rage (as 10.1 ODP.NET users also use these templates, where INullable is internal)...

Also, why did they ever decide to wrap a NULL still in a Oracle* typed object ? A null is a null, no matter what type.

Frans Bouma | Lead developer LLBLGen Pro
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 15-Apr-2008 10:41:16   

Could you give the attached template a try? (place in Templates\Oracle10gSpecific\NET2.x\C#)

Attachments
Filename File size Added on Approval
actionProcedures.template 10,625 15-Apr-2008 10:41.23 Approved
Frans Bouma | Lead developer LLBLGen Pro
Krish
User
Posts: 91
Joined: 02-Jan-2008
# Posted on: 16-Apr-2008 02:11:17   

Thanks for the template. Works beautifully. I am amazed at the determination you guys show in solving issues and solving it quickly. If you guys keep this up, Microsoft will gobble you up!

Also, why did they ever decide to wrap a NULL still in a Oracle* typed object ? A null is a null, no matter what type.

I could not agree more. Maybe you should take this up with Oracle?

By the way why dont you guys improve your template studio to make it a general purpose editor like CodeSmith tools? Is your template logic language more difficult than CodeSmith tools template logic language?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 16-Apr-2008 11:18:10   

Krish wrote:

Thanks for the template. Works beautifully. I am amazed at the determination you guys show in solving issues and solving it quickly. If you guys keep this up, Microsoft will gobble you up!

heh simple_smile Well, we hate bugs, and we even more hate waiting loooooooooong periods of time when a fix is released, so we assume our customers hate bugs and waiting long periods of time before a fix is released too wink .

Also, why did they ever decide to wrap a NULL still in a Oracle* typed object ? A null is a null, no matter what type.

I could not agree more. Maybe you should take this up with Oracle?

That's a waste of time. If some company doesn't listen even LESS to developers than microsoft it must be oracle (ok, after sybase)

By the way why dont you guys improve your template studio to make it a general purpose editor like CodeSmith tools? Is your template logic language more difficult than CodeSmith tools template logic language?

Adding intellisense is a lot of work, and as it's an add-on tool, we didn't spend that much time on intellisense in the editor. With v3, we'll revamp the template system anyway and the designer so we could merge the two, it's to be seen how much effort it takes to add intellisense to the editor simple_smile

Frans Bouma | Lead developer LLBLGen Pro