Unix Technical Forum

RE: Re: how do you convert from hex to integer using SQL ?

This is a discussion on RE: Re: how do you convert from hex to integer using SQL ? within the Informix forums, part of the Database Server Software category; --> Rajib, I played with your sql: "select '0xa' + 0 from systables where tabid = 1;" ... "It'll print ...


Go Back   Unix Technical Forum > Database Server Software > Informix

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-20-2008, 07:22 AM
Sebastian, Norma J.
 
Posts: n/a
Default RE: Re: how do you convert from hex to integer using SQL ?



Rajib,

I played with your sql: "select '0xa' + 0 from systables where tabid =
1;" ... "It'll print the integer value of the hex"

I ran this:
select tabname, partnum,
hex(partnum), ('0xa' + hex(partnum))
from systables

I get results like:

tabname ebkpf (SAP table names...)
partnum 62914738
(expression) 0x03C000B2
(expression) 62914748.0000000

tabname syschecks
partnum 1048716
(expression) 0x0010008C
(expression) 1048726.00000000

tabname syscoldepend
partnum 1048718
(expression) 0x0010008E
(expression) 1048728.00000000


Shouldn't the partnum and the second expression be equal based on your
suggestion, or am I doing something wrong?
Thanks,
Norma Jean



-----Original Message-----
From: Rajib Sarkar <rsarkar@us.ibm.com>
To: darren.edgerton@reece.com.au
Date: Wed, 5 Jan 2005 13:00:28 -0700
Subject: Re: how do you convert from hex to integer using SQL ?

Its pretty simple actually ..:-)
u can try something like:
select '0xa' + 0 from systables where tabid = 1;
It'll print the integer value of the hex. U can substitute ur column
instead of the hard-coded value in the example.
Thanx much,

Rajib Sarkar
Advisory Software Engineer
DB2/UDB Regional Advanced Support
IBM Data Management Group



darren.edgerton@r

eece.com.au

Sent by:
To
owner-informix-li informix-list@iiug.org

st@iiug.org
cc



Subject
01/05/2005 12:09 how do you convert from hex to

AM integer using SQL ?





Please respond to

darren.edgerton



Hi,
i need to conv from Hex to Integer
can this be done using SQL with Informix ??
Ie
select integer(hex_data_column) from mytable
thanks,
================================================== ==========
The information contained in this message may be privileged
and confidential and protected from disclosure. If the reader
of this message is not the intended recipient, or an employee
or agent responsible for delivering this message to the
intended recipient, you are hereby notified that any reproduction,
dissemination or distribution of this communication is strictly
prohibited. If you have received this communication in error,
please notify us immediately by replying to the message and
deleting it from your computer. Thank you. Tellabs
================================================== ==========

sending to informix-list
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-20-2008, 07:22 AM
June C. Hunt
 
Posts: n/a
Default Re: Re: how do you convert from hex to integer using SQL ?

"Sebastian, Norma J." wrote:
>
> Rajib,
>
> I played with your sql: "select '0xa' + 0 from systables where tabid =
> 1;" ... "It'll print the integer value of the hex"
>
> I ran this:
> select tabname, partnum,
> hex(partnum), ('0xa' + hex(partnum))
> from systables
>
> I get results like:
>
> tabname ebkpf (SAP table names...)
> partnum 62914738
> (expression) 0x03C000B2
> (expression) 62914748.0000000
>
> tabname syschecks
> partnum 1048716
> (expression) 0x0010008C
> (expression) 1048726.00000000
>
> tabname syscoldepend
> partnum 1048718
> (expression) 0x0010008E
> (expression) 1048728.00000000
>
>
> Shouldn't the partnum and the second expression be equal based on your
> suggestion, or am I doing something wrong?


Using Rajib's example (select '0xa' + 0 from systables where tabid = 1, I
get a constant value of 10.0000000000000. Your select is adding 10 to the
partnum, as the second expression shows.

--
June Hunt


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:41 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com