Home » SQL & PL/SQL » SQL & PL/SQL » Integer as Decimal (Oracle Database 10g Express Edition Release 10.2.0.1.0, Windows XP Pro SP3)
icon5.gif  Integer as Decimal [message #444124] Thu, 18 February 2010 15:06 Go to next message
dolot
Messages: 11
Registered: July 2009
Junior Member
I have a field in a table that is declared in the CREATE statement as an INT datatype. However, when I query that table using vb.net, the value comes back as a decimal.

How do you declare a field in Oracle as a true integer data type?

Thanks!
Re: Integer as Decimal [message #444128 is a reply to message #444124] Thu, 18 February 2010 15:32 Go to previous messageGo to next message
joy_division
Messages: 4617
Registered: February 2005
Location: East Coast USA
Senior Member
I believe the problem lies in your vb code. In Oracle, an integer is an integer. If it displays as something other than an integer, then it is the client program that is using a format mask.
Re: Integer as Decimal [message #444157 is a reply to message #444124] Thu, 18 February 2010 23:34 Go to previous messageGo to next message
Michel Cadot
Messages: 63810
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Database SQL Reference
Chapter 2 Basic Elements of Oracle SQL
Section Datatypes
Subsection ANSI, DB2, and SQL/DS Datatypes

Oracle changes INT to NUMBER datatype, VB translates NUMBER to DECIMAL but anyway it is like INTEGER inside the database.

SQL> create table t (col int);

Table created.

SQL> desc t
 Name                             Null?    Type
 -------------------------------- -------- ----------------------
 COL                                       NUMBER(38)

Regards
Michel
Re: Integer as Decimal [message #444236 is a reply to message #444157] Fri, 19 February 2010 09:21 Go to previous messageGo to next message
dolot
Messages: 11
Registered: July 2009
Junior Member
Thanks for your response. It's only a problem when we try to assign the value to an integer array. When we assign the value to an integer variable the .net framework automatically type casts. When we assign the value to an array we need to explicitly type cast, which is no big deal. I was just wondering if we had something wrong with our db design.

Thanks again.

Dave

Re: Integer as Decimal [message #444242 is a reply to message #444236] Fri, 19 February 2010 09:51 Go to previous messageGo to next message
Michel Cadot
Messages: 63810
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Nothing wrong, just implicit conversions between language.
Too bad Oracle does not recognize the INTEGER datatype as a built-in one but this would imply changing many and many things in Oracle code.

Regards
Michel

[Updated on: Fri, 19 February 2010 09:53]

Report message to a moderator

Re: Integer as Decimal [message #444243 is a reply to message #444242] Fri, 19 February 2010 09:53 Go to previous message
dolot
Messages: 11
Registered: July 2009
Junior Member
I concur. Smile
Previous Topic: missing data
Next Topic: update two table using for loop
Goto Forum:
  


Current Time: Thu Sep 29 17:33:35 CDT 2016

Total time taken to generate the page: 0.07996 seconds