In my database there is a field last_id
of type integer
. The table contains several rows. Let's say the maximum value of last_id
is 104050. Now I want to know the length of this integer.
As this is not possible I am trying to convert it into a string.
SELECT to_char(MAX(last_id),'99') FROM xxxx
I would expect this to yield 10 with type = text, but instead it returns ## type = text.
Afterwards I would use SELECT char_length(to_char(MAX(last_id),'99')) FROM xxx
which should return 2 ...
What is going wrong here?
Cast the
integer
value totext
: