From: José Soares <jose@sferacarta.com>
To: JT Kirkpatrick <jt-kirkpatrick@mpsllc.com>
Cc: 'pgsql-sql@hub.org' <pgsql-sql@hub.org>
Subject: Re: [SQL] convert text to number or number to text
Date: Thu, 22 Apr 1999 14:24:48 +0200
Message-ID: <371F1510.F86C876B@sferacarta.com> (raw)
References: <01BE8C04.0A52A9E0.jt-kirkpatrick@mpsllc.com>
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é
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jose@sferacarta.com, jt-kirkpatrick@mpsllc.com, pgsql-sql@hub.org
Subject: Re: [SQL] convert text to number or number to text
In-Reply-To: <371F1510.F86C876B@sferacarta.com>
References: <01BE8C04.0A52A9E0.jt-kirkpatrick@mpsllc.com> <371F1510.F86C876B@sferacarta.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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