From: | Karel Zak <zakkr(at)zf(dot)jcu(dot)cz> |
---|---|
To: | YekFu(dot)Wong(at)seagate(dot)com |
Cc: | yohans(at)demiurge(dot)sirius-images(dot)net, pgsql-general(at)postgresql(dot)org |
Subject: | Re: to_char function |
Date: | 2000-10-19 06:32:37 |
Message-ID: | Pine.LNX.3.96.1001019081522.24158C-100000@ara.zf.jcu.cz |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Thu, 19 Oct 2000 YekFu(dot)Wong(at)seagate(dot)com wrote:
> In case you want to convert from int to string and reversely, try
>
> $var1 = 5000;
> $var2 = sprintf ("%s", $var1); # $var2 become string
> $var3 = int ($var2); # $var3 become int
I don't understand, what do you want. The to_char() is for date/time
and number *formatting* like:
test=# select to_char(5000.123, '"I love number:" 9 9 9 9 . 999');
to_char
-------------------------------
I love number: 5 0 0 0 . 123
(1 row)
but you probably mean *cast* number to string, for this use SQL,
'::' operator or CAST() function:
test=# select 5000::text, CAST(5000 AS text);
?column? | ?column?
----------+----------
5000 | 5000
(1 row)
.. but don't forget, to your application go answers as strings/binary
data only, a standard frontend lib don't cast to some type. The cast
in query is used for internal backend processes only.
Karel
> Karel Zak <zakkr(at)zf(dot)jcu(dot)cz>@hub.org on 10/19/2000 06:46:08 AM
>
> On Wed, 18 Oct 2000, Yohans Mendoza wrote:
>
> > hi all,
> >
> > where can I find info about the function to_char
>
> Oh man.. Do you know how much hardly is for non-English person like me
> write a good documentation? And you can't found it. :-)
>
> Where.. in the PostgreSQL docs (for 7.0 or 7.1devel) of course.
> (See "formatting function"..)
>
> Karel
From | Date | Subject | |
---|---|---|---|
Next Message | Herbert Liechti | 2000-10-19 07:28:06 | updating blobs in Perl with DBD::Pg |
Previous Message | Karel Zak | 2000-10-19 06:13:05 | Re: C function and NULL result |