gswitz
asked on
Oracle Number showing extra precision
drop table temp_geoff;
create table temp_geoff (Numeric_TEST NUMBER(14,2));
grant all on temp_geoff to public ;
insert into temp_geoff(Numeric_TEST) values (4000.99);
insert into temp_geoff(Numeric_TEST) values (0);
insert into temp_geoff(Numeric_TEST) values (2077.49);
commit;
To test the returnset, use the following in a c# console app that includes a reference to Oracle...
var connString = "Data Source= (DESCRIPTION =);User Id=zzUser;Password=zzPassw ord;";
DataSet ds = new DataSet();
OracleConnection conn = new OracleConnection(connStrin g);
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "Select Numeric_TEST from temp_geoff";
cmd.CommandType = CommandType.Text;
OracleDataAdapter da = new OracleDataAdapter(cmd);
da.Fill(ds);
conn.Close();
conn.Dispose();
ds.WriteXml(AppDomain.Curr entDomain. BaseDirect ory + @"\ds_1.txt");
Process.Start("notepad.exe ", AppDomain.CurrentDomain.Ba seDirector y + @"\ds_1.txt");
These are the results regardless of which driver I choose...
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Table>
<NUMERIC_TEST>4000.9900000 000002</NU MERIC_TEST >
</Table>
<Table>
<NUMERIC_TEST>0</NUMERIC_T EST>
</Table>
<Table>
<NUMERIC_TEST>2077.4900000 000002</NU MERIC_TEST >
</Table>
</NewDataSet>
Oracle Drivers tested include
Oracle.DataAccess.dll v 2.121.1.0
Oracle.DataAccess.dll v 2.112.3.0
Oracle.DataAccess.dll v 2.112.2.0
create table temp_geoff (Numeric_TEST NUMBER(14,2));
grant all on temp_geoff to public ;
insert into temp_geoff(Numeric_TEST) values (4000.99);
insert into temp_geoff(Numeric_TEST) values (0);
insert into temp_geoff(Numeric_TEST) values (2077.49);
commit;
To test the returnset, use the following in a c# console app that includes a reference to Oracle...
var connString = "Data Source= (DESCRIPTION =);User Id=zzUser;Password=zzPassw
DataSet ds = new DataSet();
OracleConnection conn = new OracleConnection(connStrin
OracleCommand cmd = conn.CreateCommand();
cmd.CommandText = "Select Numeric_TEST from temp_geoff";
cmd.CommandType = CommandType.Text;
OracleDataAdapter da = new OracleDataAdapter(cmd);
da.Fill(ds);
conn.Close();
conn.Dispose();
ds.WriteXml(AppDomain.Curr
Process.Start("notepad.exe
These are the results regardless of which driver I choose...
<?xml version="1.0" standalone="yes"?>
<NewDataSet>
<Table>
<NUMERIC_TEST>4000.9900000
</Table>
<Table>
<NUMERIC_TEST>0</NUMERIC_T
</Table>
<Table>
<NUMERIC_TEST>2077.4900000
</Table>
</NewDataSet>
Oracle Drivers tested include
Oracle.DataAccess.dll v 2.121.1.0
Oracle.DataAccess.dll v 2.112.3.0
Oracle.DataAccess.dll v 2.112.2.0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
While you were correct about the type defined in the schema, when there is no precision defined on the number in Oracle the dataset type is still Double but the problem does not exist.
<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas- microsoft- com:xml-ms data">
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="t rue">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="A" type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
<?xml version="1.0" standalone="yes"?>
<xs:schema id="NewDataSet" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-
<xs:element name="NewDataSet" msdata:IsDataSet="true" msdata:UseCurrentLocale="t
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element name="Table">
<xs:complexType>
<xs:sequence>
<xs:element name="A" type="xs:double" minOccurs="0" />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
</xs:schema>
ASKER
Nope. I was wrong. Just had to restart the debugger. When the precision is NOT defined in Oracle, then it creates a dataset schema column type of deciimal.
ASKER
I created a new one to learn how to alter it. I've written the schema to the dataset. I just need to know how to change it.