int4 <--> varch2 conversions

From: Roland Roberts <roberts(at)panix(dot)com>
To: pgsql-general(at)postgreSQL(dot)org
Subject: int4 <--> varch2 conversions
Date: 1998-11-27 22:34:04
Message-ID: x6af1cdaub.fsf@ptolemy.rlent.pnet
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

-----BEGIN PGP SIGNED MESSAGE-----

I'm working with a PHP-based application that is using PostgreSQL in
the background. One of the tables in the application has been used
for double-duty which is causing a problem. Unfortunately, I can't
readily change the way the table is being used....

One of the columns is defined as being varchar. But sometimes it
needs to hold an int4 value. So, I need to be able to convert from
int4 to varchar and back. The actual query is:

select members.id, members.element, slips.sid, slips.problem
from slips, members
where members.element = slips.sid::varchar
and members.id = 'quickslips'

which give an error in the ::varchar cast. It also gives an error
without the cast.

I couldn't find any functions in the online manuals that will allow me
to convert back and forth. Are there any?

This is with PostgreSQL 6.3.2.

roland

-----BEGIN PGP SIGNATURE-----
Version: 2.6.2
Comment: Processed by Mailcrypt 3.4, an Emacs/PGP interface

iQCVAwUBNl8o2eoW38lmvDvNAQHWDgQAjGWOw/L/OEu75Hw5dSYbm3YXRnbFx6sv
9Wnr0RYnFx795z+7QEEUKjd37iYkgkE9zCCdtOG26T4GqpWjjNju24tngjCba+08
Y15ljI2nTnI1rPIx+eXIYQ110EhcVud87icU4DzuHbzMGn0kHp4TIKICFa2QM055
IjnuITNDax0=
=EEYK
-----END PGP SIGNATURE-----
--
Roland B. Roberts, PhD Custom Software Solutions
roberts(at)panix(dot)com 101 West 15th St #4NN
New York, NY 10011

Browse pgsql-general by date

  From Date Subject
Next Message Dmitry Iv Popov 1998-11-27 22:52:22 PostgreSQL and WWW
Previous Message Patrick Verdon 1998-11-27 14:40:12 NOTICE: SIAssignBackendId: discarding tag 2147483647