Re: parsing a string with a hexadecimal notation - Mailing list pgsql-sql

From Tom Lane
Subject Re: parsing a string with a hexadecimal notation
Date
Msg-id 20086.1107982261@sss.pgh.pa.us
Whole thread Raw
In response to Re: parsing a string with a hexadecimal notation  (Achilleus Mantzios <achill@matrix.gatewaynet.com>)
List pgsql-sql
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


pgsql-sql by date:

Previous
From: John DeSoi
Date:
Subject: Re: How to iterate through arrays?
Next
From: "Ing. Jhon Carrillo"
Date:
Subject: Function .. AS..?