pg.ddx.io pgsql-sql@postgresql.org mailing list archive
help / color / mirror / Atom feedconvert text to number or number to text
3+ messages / 2 participants
[nested] [flat]
* convert text to number or number to text
@ 1999-04-21 18:34 JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
1999-04-22 12:24 ` Re: [SQL] convert text to number or number to text José Soares <jose@sferacarta.com>
1999-04-22 12:29 ` Re: [SQL] convert text to number or number to text José Soares <jose@sferacarta.com>
0 siblings, 2 replies; 3+ messages in thread
From: JT Kirkpatrick @ 1999-04-21 18:34 UTC (permalink / raw)
To: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
I'm trying to do an update query that compares an int4 field to a variable
which I think contains a string (it was passed in through cgi.pm). can I
convert that string to an integer? - it will always be a number passing
through. I vaguely remember oracle having a to_number function - does
postgres have something similar?
jt
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [SQL] convert text to number or number to text
1999-04-21 18:34 convert text to number or number to text JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
@ 1999-04-22 12:24 ` José Soares <jose@sferacarta.com>
1 sibling, 0 replies; 3+ messages in thread
From: José Soares @ 1999-04-22 12:24 UTC (permalink / raw)
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>; +Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
JT Kirkpatrick ha scritto:
> I'm trying to do an update query that compares an int4 field to a variable
> which I think contains a string (it was passed in through cgi.pm). can I
> convert that string to an integer? - it will always be a number passing
> through. I vaguely remember oracle having a to_number function - does
> postgres have something similar?
>
> jt
Try this:
prova=> create table test(t text, i integer);
CREATE
prova=> insert into test values('123',123);
INSERT 64579 1
prova=> select cast(i as text),cast(t as int)from test;
text|int4
----+----
123| 123
(1 row)
José
^ permalink raw reply [nested|flat] 3+ messages in thread
* Re: [SQL] convert text to number or number to text
1999-04-21 18:34 convert text to number or number to text JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
@ 1999-04-22 12:29 ` José Soares <jose@sferacarta.com>
1 sibling, 0 replies; 3+ messages in thread
From: José Soares @ 1999-04-22 12:29 UTC (permalink / raw)
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>; +Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
This should work:
select cast('123' as int), cast(123 as text);
José
JT Kirkpatrick ha scritto:
> I'm trying to do an update query that compares an int4 field to a variable
> which I think contains a string (it was passed in through cgi.pm). can I
> convert that string to an integer? - it will always be a number passing
> through. I vaguely remember oracle having a to_number function - does
> postgres have something similar?
>
> jt
^ permalink raw reply [nested|flat] 3+ messages in thread
end of thread, other threads:[~1999-04-22 12:29 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
1999-04-21 18:34 convert text to number or number to text JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
1999-04-22 12:24 ` José Soares <jose@sferacarta.com>
1999-04-22 12:29 ` José Soares <jose@sferacarta.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox