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 A87378B9FB6 for ; Wed, 9 Feb 2005 20:51:20 +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 40684-05 for ; Wed, 9 Feb 2005 20:51:03 +0000 (GMT) Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by svr1.postgresql.org (Postfix) with ESMTP id 0AEAE8B9F04 for ; Wed, 9 Feb 2005 20:51:04 +0000 (GMT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id j19Kp1fR020087; Wed, 9 Feb 2005 15:51:01 -0500 (EST) To: Achilleus Mantzios Cc: =?ISO-8859-1?Q?K=D6PFERL_Robert?= , pgsql-sql@postgresql.org Subject: Re: parsing a string with a hexadecimal notation In-reply-to: References: Comments: In-reply-to Achilleus Mantzios message dated "Wed, 09 Feb 2005 15:35:25 +0200" Date: Wed, 09 Feb 2005 15:51:01 -0500 Message-ID: <20086.1107982261@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.006 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/123 X-Sequence-Number: 20234 Achilleus Mantzios writes: > You can do something like > foodb=# SELECT int4(X'FF'::bit varying); > int4 > ------ > 255 > (1 row) > but i suspect you must prepare your statement out of sql. No, I think you could do it with a placeholder if you wanted. The secret is the (poorly documented) external syntax for a hex bit string: regression=# select 'xBEEF'::bit varying; varbit ------------------ 1011111011101111 (1 row) So it should work to do "SELECT int4($1::bit varying)" and then pass 'xBEEF' as the string value for the parameter. regards, tom lane