cast hex to int in plpgsql

Started by Janek Sendrowskiover 12 years ago3 messagesgeneral
Jump to latest
#1Janek Sendrowski
janek12@web.de

Hi,

How can I realize the line?
v_res := cast(x'v_tmp' as bigint);

v_tmp is a text variable with hex digits.

this works:
v_res := cast(x'6de14a8b478ac' as bigint);

I think its about quoting

Janek

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#2Pavel Stehule
pavel.stehule@gmail.com
In reply to: Janek Sendrowski (#1)
Re: cast hex to int in plpgsql

Hello

this transformation is implemented inside parser - so you can not use a
parameters there. You can use a dynamic SQL trick

http://postgres.cz/wiki/PostgreSQL_SQL_Tricks_II#Conversion_between_hex_and_dec_numbers

Regards

Pavel

2013/12/31 Janek Sendrowski <janek12@web.de>

Show quoted text

Hi,

How can I realize the line?
v_res := cast(x'v_tmp' as bigint);

v_tmp is a text variable with hex digits.

this works:
v_res := cast(x'6de14a8b478ac' as bigint);

I think its about quoting

Janek

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Janek Sendrowski
janek12@web.de
In reply to: Pavel Stehule (#2)
Re: cast hex to int in plpgsql

Thanks!
That's what I'm searching for.
 
Janek
 

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general