Oracle Datareader - Datatype

  • Thread starter Thread starter SDF
  • Start date Start date
S

SDF

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
 
SDF said:
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
 
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
 
SDF said:
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.

--
 
Back
Top