i want to display/convert a number to character (of it's same length) using to_char() function .
In oracle i can write like
SELECT to_char(1234) FROM DUAL
But in postgres
SELECT to_char(1234)
is not working.
i want to display/convert a number to character (of it's same length) using to_char() function .
In oracle i can write like
SELECT to_char(1234) FROM DUAL
But in postgres
SELECT to_char(1234)
is not working.
You need to supply a format mask. In PostgreSQL there is no default:
If you don't know how many digits there are, just estimate the maximum:
If the number has less digits, this won't have any side effects.
If you don't need any formatting (like decimal point, thousands separator) you can also simply cast the value to text:
you have to specify a numeric format, ie:
Take a look here for more info: http://www.postgresql.org/docs/current/static/functions-formatting.html
You can use:
It works on most databases.
CAST function worked for me.
OR