[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1142
  • Last Modified:

how to convert numeric(12,2) to string in sql statement

select "baladjust" from specialmay where "cls_acct_id" = '0018100925'
I need to convert the above to something like
select string("baladjust") from specialmay where "cls_acct_id" = '0018100925'

The reason is I'm running this statement in C#.NET and its reading the database value 5.68 as 5 in the resultset. Why? I don't know. But I'm grasping at straws.

0
claghorn
Asked:
claghorn
  • 3
1 Solution
 
earth man2Commented:
simple way is to use function to_char()

select to_char(number_column_name) from your_table;
0
 
earth man2Commented:
test=> create table d ( col1 numeric(5,2) );
CREATE TABLE
test=> insert into d values ( 4.56 );
INSERT 49199 1
test=> select to_char(col1,'99999.99') from d;
  to_char  
-----------
      4.56
(1 row)
0
 
claghornAuthor Commented:
Select to_char("baladjust") from specialmay where "cls_acct_id" = '0018100925'

ERROR:  function to_char(numeric) does not exist
HINT:  No function matches the given name and argument types. You may need to add explicit type casts.
0
 
earth man2Commented:
you need to specify a format string ie

select to_char(col1,'99999.99') from d;
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now