Oracle Datareader - Datatype

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
 
D

David Browne

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
 
E

Eric

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
 
F

Frans Bouma [C# MVP]

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.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top