Code Monkey home page Code Monkey logo

Comments (5)

tgulacsi avatar tgulacsi commented on July 27, 2024

It's not zhat easy: insert 191/200 in Oracle DB into a num NUMBER column.
That's 0.955.
Then SELECT num-0.955 FROM table.
That will be 10^-39.

I don't think that hiding this in a driver would do any good...

from odpi.

kubo avatar kubo commented on July 27, 2024

@tgulacsi
Could you post details? What programming language or tool did you use? How did you insert and fetch numbers?
I cannot reproduce it by sqlplus and rust-oracle.

I think that the inserted value is not 0.955.
If it is exactly 0.955, SELECT dump(num) FROM table is Typ=2 Len=3: 192,96,51.
I guess that dump(num) is Typ=2 Len=21: 192,96,51,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,?? (0.95500000000000000000000000000000000000??) in the your table because num-0.955 is 10^-39.

from odpi.

tgulacsi avatar tgulacsi commented on July 27, 2024

You're right, it depends on the column's data type - NUMBER works as expected,
but if you specify a precision, it degrades to using floating-point:

CREATE TABLE w_gt_test_n (n NUMBER, n38 NUMBER(38,38)) TABLESPACE DATA;
INSERT INTO W_gt_test_n VALUES (0.955, 0.955);
INSERT INTO W_gt_test_n VALUES (191/200, 191/200);
SELECT n, DUMP(n), n38, DUMP(n38), DUMP(n-n38) FROM w_gt_test_n;
DROP TABLE w_gt_test_n;

PL/SQL Developer (Delphi):

N	DUMP(N)	N38	DUMP(N38)	DUMP(N-N38)
0,955	Typ=2 Len=3: 192,96,51	0,95500000000000013	Typ=2 Len=3: 192,96,51	Typ=2 Len=1: 128
0,955	Typ=2 Len=3: 192,96,51	0,95500000000000013	Typ=2 Len=3: 192,96,51	Typ=2 Len=1: 128

SQL*Plus:

         N
----------
DUMP(N)
--------------------------------------------------------------------------------
       N38
----------
DUMP(N38)
--------------------------------------------------------------------------------
DUMP(N-N38)
--------------------------------------------------------------------------------
      ,955
Typ=2 Len=3: 192,96,51
      ,955
Typ=2 Len=3: 192,96,51
Typ=2 Len=1: 128

      ,955
Typ=2 Len=3: 192,96,51
      ,955
Typ=2 Len=3: 192,96,51
Typ=2 Len=1: 128

So yes, I've also fallen: it's only the displaying library's error.

from odpi.

kubo avatar kubo commented on July 27, 2024

I think that the feature is useful for node-oracledb. But it isn't for cx_Oracle (if I don't misunderstand this) and rust-oracle because they use DPI_NATIVE_TYPE_BYTES for numbers and access numbers via strings.
If it isn't useful for drivers other than what I checked, feel free to close it. If only one driver needs it, it is almost dead code.

Well, I thought that cx_Python also used DPI_NATIVE_TYPE_DOUBLE for numbers as node-oracledb did and it was worth to add the feature. But cx_Python have used DPI_NATIVE_TYPE_BYTES for numbers since this commit. I'm not sure now whether it is worth or not.

from odpi.

cjbj avatar cjbj commented on July 27, 2024

We'll definitely evaluate it.

from odpi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.