X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 3805455F51 for ; Mon, 14 Mar 2005 17:31:31 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 96954-06 for ; Mon, 14 Mar 2005 17:31:21 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.195]) by svr1.postgresql.org (Postfix) with ESMTP id 66109567C6 for ; Mon, 14 Mar 2005 17:31:20 +0000 (GMT) Received: by wproxy.gmail.com with SMTP id 68so1947240wra for ; Mon, 14 Mar 2005 09:31:20 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:references; b=t1NqyyIbpuy4uPHLzJP1m1ZNhhn/0bok0THasZvFraDzLvlx8eePOk2bDAIneDJjF7dC6trSyi/zhQH+xQwoYp38cvU+WZmK7IR70+sQWVN4VbvJmU3Oav2qHGTcXmKPlbCla9IchWFvPiSarV5iqRidVNn7Dg9QEUFaMYt77ks= Received: by 10.54.65.13 with SMTP id n13mr3565973wra; Mon, 14 Mar 2005 09:31:20 -0800 (PST) Received: by 10.54.57.33 with HTTP; Mon, 14 Mar 2005 09:31:20 -0800 (PST) Message-ID: Date: Mon, 14 Mar 2005 10:31:20 -0700 From: Lance Peterson Reply-To: Lance Peterson To: pgsql-sql@postgresql.org Subject: Re: How to cast VARCHAR to BYTEA and vice-versa? In-Reply-To: <4235683A.6D2CA65A@rodos.fzk.de> Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit References: <4235683A.6D2CA65A@rodos.fzk.de> X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.398 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, RCVD_BY_IP X-Spam-Level: X-Archive-Number: 200503/200 X-Sequence-Number: 20679 Christoph, is that recent functionality? I'm running 7.4 and I get: ERROR: cannot cast type text to bytea I get similar errors when trying to go the other direction. On Mon, 14 Mar 2005 11:32:26 +0100, Christoph Haller wrote: > "Moran.Michael" wrote: > > > > Hello all, > > > > I have a table with a VARCHAR column that I need to convert to a BYTEA. > > > > How do I cast VARCHAR to BYTEA? > > > > The following doesn't seem to work as it yields the 'cannot cast varchar to > > bytea' error message: > > > > varchar_data::bytea > > > > On the same topic, how do I do the reverse, that is, how to I cast from > > BYTEA back to VARCHAR? > > > > Thanks, > > -Michael Moran > > > > > As far as I remember > varchar_data::TEXT::BYTEA > works. Vice versa dto. > Be aware BYTEA data may contain character codes > unconvertable to VARCHAR, especially '\0'. > > Regards, Christoph > > ---------------------------(end of broadcast)--------------------------- > TIP 5: Have you checked our extensive FAQ? > > http://www.postgresql.org/docs/faq >