Type Conversion Oracle & SQL Error

Posts   
 
    
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 28-Nov-2011 21:36:35   

Hi,

I am using llblgen v3.1, SQL Server 2008 and Oracle 11g.

I have field which is defined decimal(10,2) in sql, Number (10,2) in oracle and .Net type for both should be decimal as per documentation.

http://msdn.microsoft.com/en-us/library/cc716729.aspx

http://msdn.microsoft.com/en-us/library/cc716726.aspx

When i am mapping this table to same entity in llblgen designer, It is giving me error, "The .net type of the mapped element field and target field aren't the same, so type converted needed." When i am looking at target element details pane, SQL decimal is converted to decimal but oracle number is converted to double in .net type.

Can anybody guide me on this, how i can resolve this issue.

Rishi

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 29-Nov-2011 02:46:28   

Rishi wrote:

I am using llblgen v3.1, SQL Server 2008 and Oracle 11g.

I have field which is defined decimal(10,2) in sql, Number (10,2) in oracle and .Net type for both should be decimal as per documentation.

http://msdn.microsoft.com/en-us/library/cc716729.aspx

http://msdn.microsoft.com/en-us/library/cc716726.aspx

Hi Rishi. It's not that simple. The scale/precision matters in oracle and the ado.net driver (either MS or ODP).

If you want a number from Oracle DB to be mapped onto a decimal you must increase the precision (>= 16). If modifying the DB schema is not an option, you can opt for writing a TypeConverter that converts from/to DB double to/from .net decimal. There is a lot of information about writing a TypeConverter in this forum, you can also download the source code package that contains a numeric/boolean typeConverter.

These are some related threads about how SqlServer/Oracle types are mapped: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=897 http://llblgen.com/tinyforum/Messages.aspx?ThreadID=3029 http://llblgen.com/tinyforum/Messages.aspx?ThreadID=15275

David Elizondo | LLBLGen Support Team
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 29-Nov-2011 17:14:08   

Thanks for your reply..

I am trying to use Type converter, but it seems like not working for me please guide me. here is what i am trying to do..

I have SQL Server 2008 and oracle 9i, LLBLGen 3.1..

SQL Field defined as decimal(10,2) which is converted .net type as system.decimal. Oracle Field defined as Number(10,2) which is converted .net type as double.

I have mapped sql server fields first in LLBLGen designer and then manually mapping entities to oracle database.

I wanted to use type converted on oracle database to resolve this issue.When i am trying to add type converter from single/double , there is no converter in drop box to select, so please guide me how i can resolve this issue.

Rishi

daelmo wrote:

Rishi wrote:

I am using llblgen v3.1, SQL Server 2008 and Oracle 11g.

I have field which is defined decimal(10,2) in sql, Number (10,2) in oracle and .Net type for both should be decimal as per documentation.

http://msdn.microsoft.com/en-us/library/cc716729.aspx

http://msdn.microsoft.com/en-us/library/cc716726.aspx

Hi Rishi. It's not that simple. The scale/precision matters in oracle and the ado.net driver (either MS or ODP).

If you want a number from Oracle DB to be mapped onto a decimal you must increase the precision (>= 16). If modifying the DB schema is not an option, you can opt for writing a TypeConverter that converts from/to DB double to/from .net decimal. There is a lot of information about writing a TypeConverter in this forum, you can also download the source code package that contains a numeric/boolean typeConverter.

These are some related threads about how SqlServer/Oracle types are mapped: http://llblgen.com/tinyforum/Messages.aspx?ThreadID=897 http://llblgen.com/tinyforum/Messages.aspx?ThreadID=3029 http://llblgen.com/tinyforum/Messages.aspx?ThreadID=15275

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 30-Nov-2011 04:35:53   

Rishi wrote:

SQL Field defined as decimal(10,2) which is converted .net type as system.decimal. Oracle Field defined as Number(10,2) which is converted .net type as double.

The SQLServer fields are ok. You need a double/decimal TypeConverter, so it converts from DB double to .net decimal. Please see the example of the NumericBoolean typeConverter at the sourcode for more info about how to work on this.

Post your current TypeConverter code to take a look at it.

David Elizondo | LLBLGen Support Team