I have a table in 9.2 and a field as INT. When I use an OracleDataReader to
query the table the field is being returned as Decimal. Being not to
familiar with Oracle does anyone have an idea why?

CREATE TABLE DWSDLAYERS (
LAYERID NUMBER,
LAYERNAME VARCHAR2 (128),
LAYERTYPE NUMBER NOT NULL,
LAYERDESCRIPTION VARCHAR2 (3000),
FEATURETYPE NUMBER DEFAULT 1)
TABLESPACE USERS NOLOGGING
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE (
INITIAL 65536
MINEXTENTS 1
MAXEXTENTS 2147483645
)


Query = "Select LAYERID, CATEGORY, DESCRIPTION, LAYERTYPE, FEATURETYPE from
DWSDLAYERS where LAYERNAME = :LAYERNAME"


Debug Ouput:

?OraReader("FEATURETYPE")
1D {Decimal}
[Decimal]: 1D

Re: Oracle Datareader - Datatype by David

David
Wed Jan 26 17:25:24 CST 2005


"SDF" <sdf@nospam.com> wrote in message
news:uoHsie$AFHA.904@TK2MSFTNGP12.phx.gbl...
>I have a table in 9.2 and a field as INT. When I use an OracleDataReader
>to
> query the table the field is being returned as Decimal. Being not to
> familiar with Oracle does anyone have an idea why?
>
> CREATE TABLE DWSDLAYERS (
> LAYERID NUMBER,
> LAYERNAME VARCHAR2 (128),
> LAYERTYPE NUMBER NOT NULL,
> LAYERDESCRIPTION VARCHAR2 (3000),
> FEATURETYPE NUMBER DEFAULT 1)
> TABLESPACE USERS NOLOGGING
> PCTFREE 10
> INITRANS 1
> MAXTRANS 255
> STORAGE (
> INITIAL 65536
> MINEXTENTS 1
> MAXEXTENTS 2147483645
> )

Oracle 9.2 does not really have a SQL type of "INT". INT is an ANSI
standard type, and in Oracle it's mapped to NUMBER.

David



Re: Oracle Datareader - Datatype by Eric

Eric
Wed Jan 26 21:46:27 CST 2005

You can cast it to an int.

Be careful about any col's that might return a NULL - it will raise an
exception if you don't check for it before trying to assign it to a C# type.

Eric

Re: Oracle Datareader - Datatype by Frans

Frans
Thu Jan 27 03:36:55 CST 2005

SDF wrote:
> I have a table in 9.2 and a field as INT. When I use an OracleDataReader to
> query the table the field is being returned as Decimal. Being not to
> familiar with Oracle does anyone have an idea why?
>
> CREATE TABLE DWSDLAYERS (
> LAYERID NUMBER,
> LAYERNAME VARCHAR2 (128),
> LAYERTYPE NUMBER NOT NULL,
> LAYERDESCRIPTION VARCHAR2 (3000),
> FEATURETYPE NUMBER DEFAULT 1)
> TABLESPACE USERS NOLOGGING
> PCTFREE 10
> INITRANS 1
> MAXTRANS 255
> STORAGE (
> INITIAL 65536
> MINEXTENTS 1
> MAXEXTENTS 2147483645
> )
>
>
> Query = "Select LAYERID, CATEGORY, DESCRIPTION, LAYERTYPE, FEATURETYPE from
> DWSDLAYERS where LAYERNAME = :LAYERNAME"
>
>
> Debug Ouput:
>
> ?OraReader("FEATURETYPE")
> 1D {Decimal}
> [Decimal]: 1D

AS you haven't specified any precision nor scale for NUMBER, the
default will be oracle's default which is precision 38. A NUMBER(38,0)
will be read into a System.Decimal instance.

Frans.

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------