Error Cannot Cast Type Text To Bytea
pgsql-announce pgsql-bugs pgsql-docs pgsql-general pgsql-interfaces pgsql-jobs pgsql-novice pgsql-performance pgsql-php pgsql-sql pgsql-students Developer lists Regional lists Associations User groups Project lists Inactive lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News Cast text to bytea From: Alvar Freude To: pgsql-general(at)postgresql(dot)org Subject: Cast text to bytea Date: 2003-12-03 08:33:37 Message-ID: 1188110000.1070440417@gnarzelwicht.delirium-arts.de (view raw or whole thread) Thread: 2003-12-03 08:33:37 from Alvar Freude 2003-12-03 09:36:59 from Alvar Freude 2003-12-03 13:23:27 from Alvar Freude Lists: pgsql-general -----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: odem=> UPDATE forum_gtree SET gid2=gid::bytea; ERROR: Cannot cast type text to bytea The same with casting only: odem=> SELECT 'abc'::text::bytea; ERROR: Cannot cast type text to bytea odem=> SELECT '\000'::text::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 And in http://www.postgresql.org/docs/current/static/datatype-binary.html I also found no solution -- perhaps I missed something? 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/zZ/hOndlH63J86wRAmvoAJ4jwJp5R0nrmf8FzG9O599ED/8eCgCeOO2L RpqleJNIv5RKvorYzh5+lo4= =7mYs -----END PGP SIGNATURE----- Responses Re: Cast text to bytea at 2003-12-03 09:36:59 from Alvar Freude pgsql-general by date Next:From: Richard HuxtonDate: 2003-12-03 09:03:30 Subject: Re: Transaction Question Previous:From: David GaramondDate: 2003-12-03 08:27:14 Subject: Re: Money data type i
pgsql-announce pgsql-bugs pgsql-docs pgsql-general pgsql-interfaces pgsql-jobs pgsql-novice pgsql-performance pgsql-php pgsql-sql pgsql-students Developer lists Regional lists Associations User groups Project lists Inactive lists IRC Local User Groups Featured Users International Sites Propaganda Resources Weekly News Re: Cast text to bytea From: Godshall Michael To: 'Alvar Freude' , 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 (view raw or whole thread) Thread: 2003-12-02 https://www.postgresql.org/message-id/1188110000.1070440417@gnarzelwicht.delirium-arts.de 23:19:07 from Godshall Michael 2003-12-03 08:33:41 from Alvar Freude 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 https://www.postgresql.org/message-id/A596FA3368757645AF862C701495CA0001B44A38@hor1mspmx01.gmachs.com 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 Re: Cast text to bytea at 2003-12-03 08:33:41 from Alvar Freude pgsql-a
Reichstadt Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Altering column type from text to bytea Hi,when http://postgresql.nabble.com/Altering-column-type-from-text-to-bytea-td5583964.html trying to change a text column to bytea I am getting the following error:SQL error:ERROR: column "comment" cannot be cast to type byteaIn statement:ALTER TABLE "public"."persons" ALTER COLUMN "comment" TYPE byteaI found that others had the same issue but I found no solution for it. I made a test-table and though it was empty meaning the column of concern had only NULL error cannot values I got the same error when trying to change that text column to type bytea.Is it possible to change column types later on to bytea?ThanksAlex Alexander Reichstadt Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: Altering column type from text to bytea I just found a thread that outlines this error cannot cast issue and how to solve it here:ThanksAlexAm 21.03.2012 um 20:56 schrieb Alexander Reichstadt:Hi,when trying to change a text column to bytea I am getting the following error:SQL error:ERROR: column "comment" cannot be cast to type byteaIn statement:ALTER TABLE "public"."persons" ALTER COLUMN "comment" TYPE byteaI found that others had the same issue but I found no solution for it. I made a test-table and though it was empty meaning the column of concern had only NULL values I got the same error when trying to change that text column to type bytea.Is it possible to change column types later on to bytea?ThanksAlex Merlin Moncure-2 Reply | Threaded Open this post in threaded view ♦ ♦ | Report Content as Inappropriate ♦ ♦ Re: Altering column type from text to bytea In reply to this post by Alexander Reichstadt On Wed, Mar 21, 2012 at 2:56 PM, Alexander Reichstadt <[hidden email]> wrote: Hi,when trying to change a text column to bytea I am getting the following error: SQL error: ERROR: column "comment" cannot be cast to type bytea In statement:ALTER TABLE "public"."persons" ALTER COLUMN "comment" TYPE byteaTRY ALT