Home » SQL & PL/SQL » SQL & PL/SQL » Problem with NUMBER datatype
Problem with NUMBER datatype [message #244667] Wed, 13 June 2007 12:37 Go to next message
celiceblank
Messages: 1
Registered: June 2007
Junior Member
Hi,

In my database, I got a table with a field named 'charge', datatype NUMBER (12,2)
The PL/SQL script to get this field value from the database is as below:

svc_charge some_charges.charge%type;

select charge into v_svc_charge
from some_charges
where type = "some_value"
and id = "some_value";

When i set this field as 10.5 in my database, I got the output as 11. And when I set it as 10.3, the output is automatically round off to 10.

Am I using the correct datatype to store a real value like 10.5 ? If not what is the datatype I should use?

Thanks in advance,
Celice
Re: Problem with NUMBER datatype [message #244668 is a reply to message #244667] Wed, 13 June 2007 12:49 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Post a "desc" of some_charges.
How do you know that the values are 11 and 10?

Regards
Michel
Re: Problem with NUMBER datatype [message #244672 is a reply to message #244667] Wed, 13 June 2007 13:31 Go to previous messageGo to next message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
You are setting the type of svc_charge but you are using v_svc_charge as your variable.
Re: Problem with NUMBER datatype [message #244684 is a reply to message #244672] Wed, 13 June 2007 13:57 Go to previous messageGo to next message
Michel Cadot
Messages: 64139
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Good eye!

Regards
Michel
Re: Problem with NUMBER datatype [message #244689 is a reply to message #244684] Wed, 13 June 2007 14:35 Go to previous message
joy_division
Messages: 4643
Registered: February 2005
Location: East Coast USA
Senior Member
My first inclination was just to repeat what you said, but I figured I'd look a little deeper and then saw the difference. However, I am guessing now that the OP did not do a cut and paste and simply retyped the whole thing, making a typo.

I am basing that on the fact that double quotes are being used instead of single quotes and this would fail since the variable of the INTO clause does not exist.
Previous Topic: Different day result from PL/SQL and SQL
Next Topic: materialized view refresh part of a bigger transaction
Goto Forum:
  


Current Time: Thu Dec 08 20:14:45 CST 2016

Total time taken to generate the page: 0.24570 seconds