Re: parsing a string with a hexadecimal notation

From: Achilleus Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
To: KÖPFERL Robert <robert(dot)koepferl(at)sonorys(dot)at>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: parsing a string with a hexadecimal notation
Date: 2005-02-09 13:35:25
Message-ID: Pine.LNX.4.44.0502091526170.8966-100000@matrix.gatewaynet.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

O KΦPFERL Robert έγραψε στις Feb 9, 2005 :

> I intend to retrieve an int value in an integer variable from a string with
> a hexadecimal notation of a number.
> Which function is appropriate to do
> i int4
> i = ???('BEAF')

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.

E.g. in java:

String hex="FF";
st = con.prepareStatement("select int4(X'"+hex+"'::bit varying");

>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org
>

--
-Achilleus

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message NosyMan 2005-02-09 13:59:08 How to iterate through arrays?
Previous Message KÖPFERL Robert 2005-02-09 11:01:31 parsing a string with a hexadecimal notation