Home » SQL & PL/SQL » SQL & PL/SQL » NUMBER with One precision (10g)
NUMBER with One precision [message #391728] Fri, 13 March 2009 04:07 Go to next message
McLan
Messages: 36
Registered: April 2008
Member
I have table called employee as below:
Create table empsal
{
	NAME varchar2(255 BYTE),
	SAL NUMBER
};

when I insert data as below:
insert into empsal (NAME,SAL) values ('Mr.James', 2000.0);

when I query to get the data the sal is shown as 2000 but not as 2000.0, the table is not storing the data as 2000.0, I want table to store the data as 2000.0, what changes I need to do?

Regards,

[Mod-edit: Frank removed quote-tags]

[Updated on: Fri, 13 March 2009 04:21] by Moderator

Report message to a moderator

Re: NUMBER with One precision [message #391734 is a reply to message #391728] Fri, 13 March 2009 04:20 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
The number is stored as a number. What you see is the string-represenation of it.
If you want to control your output, convert your number to a string explicitly (using to_char with the desired format mask)
Re: NUMBER with One precision [message #391739 is a reply to message #391728] Fri, 13 March 2009 05:18 Go to previous messageGo to next message
McLan
Messages: 36
Registered: April 2008
Member
Thanks for the suggestion, I tried with below(as you suggested) and it works,

Select to_char(empsal,'9999.9') from empsal;


If I have millions of records in the table, does this have performance impact to call to_char function for each record?

[Mod-Edit: Frank removed QUOTE-tags again]

[Updated on: Fri, 13 March 2009 05:34] by Moderator

Report message to a moderator

Re: NUMBER with One precision [message #391746 is a reply to message #391739] Fri, 13 March 2009 05:36 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
If this is the output-format you need, then the performance loss (which is neglectible, by the way) is just a pity.
Functionality is more important than performance.


Please only use QUOTE tags for texts you quote from other people. Regular text should not be inside tags.
Previous Topic: PLSQL Generic Packge Which creates package and package body based on table name
Next Topic: how is it possible??? (Column In Rows)
Goto Forum:
  


Current Time: Mon Dec 05 23:53:22 CST 2016

Total time taken to generate the page: 0.20063 seconds