Re: Cast text to bytea

From: Godshall Michael <Michael_Godshall(at)gmachs(dot)com>
To: 'Alvar Freude' <alvar(at)a-blast(dot)org>, pgsql-admin(at)postgresql(dot)org
Subject: Re: Cast text to bytea
Date: 2003-12-02 23:19:07
Message-ID: A596FA3368757645AF862C701495CA0001B44A38@hor1mspmx01.gmachs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Have you seen this?
http://www.postgresql.org/docs/current/static/datatype-binary.html

Maybe you need some backslashes?

-----Original Message-----
From: pgsql-admin-owner(at)postgresql(dot)org
[mailto:pgsql-admin-owner(at)postgresql(dot)org]On Behalf Of Alvar Freude
Sent: Tuesday, December 02, 2003 5:07 PM
To: pgsql-admin(at)postgresql(dot)org
Subject: [ADMIN] Cast text to bytea

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I want to change a column from text to bytea; since it seems that alter
table can't change the column type, i have to add a temporary column and
copy the data from the old one to the new, delete the old and rename the
new.

But it seems that Postgres can't cast text to bytea:

> UPDATE forum_gtree SET gid2=gid::bytea;
ERROR: Cannot cast type text to bytea

How can I do this?

encode/decode seems to handle only bytea data:

http://www.postgresql.org/docs/current/interactive/functions-string.html

Thanks && Ciao
Alvar

- --
** Alvar C.H. Freude -- http://alvar.a-blast.org/
** Berufsverbot? http://odem.org/aktuelles/staatsanwalt.de.html
** ODEM.org-Tour: http://tour.odem.org/
** Informationsgesellschaft: http://www.wsis-koordinierungskreis.de/

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (FreeBSD)

iD8DBQE/zRsgOndlH63J86wRAn4aAJ0aY9Td3YcWwkIwdALInCXaruINcgCgoDtx
FQmuBKPACLfE5YAmMTdCN4g=
=OivL
-----END PGP SIGNATURE-----

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Renney Thomas 2003-12-03 04:19:21 PGSQL and DNCL
Previous Message Alvar Freude 2003-12-02 23:07:12 Cast text to bytea