From: Tom Lane <tgl@sss.pgh.pa.us>
To: Achilleus Mantzios <achill@matrix.gatewaynet.com>
Cc: KÖPFERL Robert <robert.koepferl@sonorys.at>
Cc: pgsql-sql@postgresql.org
Subject: Re: parsing a string with a hexadecimal notation
Date: Wed, 09 Feb 2005 15:51:01 -0500
Message-ID: <20086.1107982261@sss.pgh.pa.us> (raw)
In-Reply-To: <Pine.LNX.4.44.0502091526170.8966-100000@matrix.gatewaynet.com>
References: <Pine.LNX.4.44.0502091526170.8966-100000@matrix.gatewaynet.com>
Achilleus Mantzios <achill@matrix.gatewaynet.com> 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, achill@matrix.gatewaynet.com, robert.koepferl@sonorys.at
Subject: Re: parsing a string with a hexadecimal notation
In-Reply-To: <20086.1107982261@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox