Store procedure mapping SQL & Oracle

Posts   
 
    
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 30-Nov-2011 17:48:37   

Hi,

I am using LLBLGen 3.1, Oracle 11i & SQL 2008

I am store procedure which i am trying to map, to oracle and sql database in llblgen designer. Variable datatype for this store procedure is defined as "Int" in SQL and "Number" in oracle. .net type for this coming as Int32 for sql and decimal for oracle. I am trying to change oracle procedure to make .net type to Int32. I have tried Int and Integer but both are giving me decimal only. Can you suggest, what should i used to get same .net type in oracle and sql.

Thanks...

Rishi

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 30-Nov-2011 18:30:39   

Any of the following should work: number(5, 0) System.Int32 number(6, 0) System.Int32 number(7, 0) System.Int32 number(8, 0) System.Int32 number(9, 0) System.Int32

Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 30-Nov-2011 21:01:04   

I can not provide this in oracle package as parameter. Do you have any idea how i can do this?

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Dec-2011 04:31:19   

Rishi wrote:

I can not provide this in oracle package as parameter. Do you have any idea how i can do this?

I don't understand. You are changing the type of a parameter in the SP definition in Oracle, so you can try the types suggested by Walaa.

David Elizondo | LLBLGen Support Team
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 01-Dec-2011 16:00:24   

I am trying to explain you my problem once again...

I am using LLBNGen 3.1, SQL 2008 and Oracle 11i. i am using store procedure to get output from database. Store procedure input parameter is defined as INT in SQL and Number in Oracle. I am getting type conversion error because its defined as number and .net type for this is double. Walaa suggested me to change this type to Number(8,0) so .net type of this will be Int32. I can understand this and it make sense.. but in oracle when you define package, which contain store procedure will accept only number as in parameter, I can not give Number(8,0) there? Try out this to make sure... or i am doing something wrong..

Please guide me on this...

Rishi

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 01-Dec-2011 18:55:28   

I recall that it indeed could be done. But anyway, talking ab out SPs, oracle doesn't return any precision/scale information on SP's parameters when querying its metadata. So what I would recommend you is write a TypeConverter which converts from/to db .net double to/from .net int32. Then you can change the type of any parameter of the SP call in LLBLGen Designer and assign the TypeConverter to it.

Let us know if you need further help when writing the TypeConverter.

David Elizondo | LLBLGen Support Team
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 02-Dec-2011 17:37:56   

Hi,

As you suggested i wrote custom type converter, complied under .net framework 2.0 and placed dll into TypeConverter folder of llblgen pro. I am not getting my type converter into list of "TypeConverter to use" under entities. I tried to debug my code, but its not hitting break point. Please guide me on this..

My Code:

Public Class DoubleConverter Inherits System.ComponentModel.TypeConverter

' Overrides the CanConvertFrom method of TypeConverter. ' The ITypeDescriptorContext interface provides the context for the ' conversion. Typically, this interface is used at design time to ' provide information about the design-time container. Public Overloads Overrides Function CanConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal sourceType As Type) As Boolean If sourceType Is GetType(Double) Then Return True End If Return MyBase.CanConvertFrom(context, sourceType) End Function

Public Overrides Function CanConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal destinationType As System.Type) As Boolean If destinationType Is GetType(Double) Then Return True End If Return MyBase.CanConvertTo(context, destinationType) End Function

' Overrides the ConvertFrom method of TypeConverter. Public Overloads Overrides Function ConvertFrom(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object) As Object If TypeOf value Is Double Then Return Convert.ToInt32(value) End If Return MyBase.ConvertFrom(context, culture, value) End Function

' Overrides the ConvertTo method of TypeConverter. Public Overloads Overrides Function ConvertTo(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal culture As System.Globalization.CultureInfo, ByVal value As Object, ByVal destinationType As Type) As Object If destinationType Is GetType(Double) Then Return Convert.ToInt32(value) End If Return MyBase.ConvertTo(context, culture, value, destinationType) End Function

Public Overrides Function CreateInstance(ByVal context As System.ComponentModel.ITypeDescriptorContext, ByVal propertyValues As System.Collections.IDictionary) As Object Return MyBase.CreateInstance(context, propertyValues) End Function

End Class

Thanks

Rishi

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Dec-2011 21:42:15   

ConvertFrom should convert the passed Double and return an Int. ConvertTo should convert the passed Int and return a Double. CreateInstance should create a dummy Int. (It could be Integer.Min).

David Elizondo | LLBLGen Support Team
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 02-Dec-2011 23:04:12   

Thanks It worked..