I am currently returning an sql result with a number value that I want to format as an amount. The sql runs smoothly on its own, but when run inside my ksh script an error is encountered:
ERROR at line 3:
ORA-01481: invalid number format model
My sql is --
select distinct
to_char(amount,'$9,999,999,999.00')
from account;
The amount field in the account table is already defined as a number. Is there a specific way for me to return this value with the $9,999,999,999.00 format?
The problem is becuase of the $9,999,999,999. When you run this query in sql, it will work fine. When you run this from shell, shell interprets $9,999,999,999(since there is a $ in it) as a variable name and tries to replace the value in it.
Remove the $ in the to_char and run it, and you can prepend the $ later in the output.