dbTalk Databases Forums  

Oracle hexadecimal query

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Oracle hexadecimal query in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #31  
Old   
nivS1978@gmail.com
 
Posts: n/a

Default Re: Oracle hexadecimal query - 03-14-2008 , 09:09 AM






On Mar 7, 12:16*am, Urs Metzger <u... (AT) ursmetzger (DOT) de> wrote:
Quote:
DA Morgan schrieb:





Urs Metzger wrote:
nivS1... (AT) gmail (DOT) com schrieb:
A quick and simple question.

If I have a query like:
SELECT * FROM table NUM = 31

Now for reasons irelevant to my question the number provided is
hexadecimal. I could ofcourse in the program convert this to a number
but is there a syntax in oracle to use similar to the sql server:
SELECT * FROM table NUM = 0x1F

How do I write this in oracle?

I know I can do a to_num('1F','XX') or something like that but is
there a way to just write a hexadecimal number directly?

Regards Hans Milling...

Hans,

there is no way to express a number in hexadecimal format directly.
This has not changed between at least 8.1.7 and 11.1.
Search the SQL Language Reference provided on
tahiti.oracle.com for "Literals".

Of course there is no need to convert the table data to hexadecimal,
but you do have to convert the hexadecimal representation '1F'
to the type in your table.

HtH,
Urs Metzger

I would suspect you would create a user-defined data type and use
it to build a table that would do this: But why?

As the op clearly states, NUM is a numeric (integer) column, so I would
convert the query parameter '1F' into a number using TO_NUMBER (what else?).

SQL> create table t (num integer);

Tabelle wurde erstellt.

SQL> insert into t values(31);

1 Zeile wurde erstellt.

SQL> select * from t where num = to_number('1F', 'XX');

* * * * NUM
----------
* * * * *31

No need to "convert the table data to hexadecimal".

It's that simple.

Urs Metzger- Hide quoted text -

- Show quoted text -
Thanks for your reply. This is the solution I have chosen to use.


Reply With Quote
  #32  
Old   
nivS1978@gmail.com
 
Posts: n/a

Default Re: Oracle hexadecimal query - 03-14-2008 , 09:09 AM






On Mar 7, 12:16*am, Urs Metzger <u... (AT) ursmetzger (DOT) de> wrote:
Quote:
DA Morgan schrieb:





Urs Metzger wrote:
nivS1... (AT) gmail (DOT) com schrieb:
A quick and simple question.

If I have a query like:
SELECT * FROM table NUM = 31

Now for reasons irelevant to my question the number provided is
hexadecimal. I could ofcourse in the program convert this to a number
but is there a syntax in oracle to use similar to the sql server:
SELECT * FROM table NUM = 0x1F

How do I write this in oracle?

I know I can do a to_num('1F','XX') or something like that but is
there a way to just write a hexadecimal number directly?

Regards Hans Milling...

Hans,

there is no way to express a number in hexadecimal format directly.
This has not changed between at least 8.1.7 and 11.1.
Search the SQL Language Reference provided on
tahiti.oracle.com for "Literals".

Of course there is no need to convert the table data to hexadecimal,
but you do have to convert the hexadecimal representation '1F'
to the type in your table.

HtH,
Urs Metzger

I would suspect you would create a user-defined data type and use
it to build a table that would do this: But why?

As the op clearly states, NUM is a numeric (integer) column, so I would
convert the query parameter '1F' into a number using TO_NUMBER (what else?).

SQL> create table t (num integer);

Tabelle wurde erstellt.

SQL> insert into t values(31);

1 Zeile wurde erstellt.

SQL> select * from t where num = to_number('1F', 'XX');

* * * * NUM
----------
* * * * *31

No need to "convert the table data to hexadecimal".

It's that simple.

Urs Metzger- Hide quoted text -

- Show quoted text -
Thanks for your reply. This is the solution I have chosen to use.


Reply With Quote
  #33  
Old   
nivS1978@gmail.com
 
Posts: n/a

Default Re: Oracle hexadecimal query - 03-14-2008 , 09:09 AM



On Mar 7, 12:16*am, Urs Metzger <u... (AT) ursmetzger (DOT) de> wrote:
Quote:
DA Morgan schrieb:





Urs Metzger wrote:
nivS1... (AT) gmail (DOT) com schrieb:
A quick and simple question.

If I have a query like:
SELECT * FROM table NUM = 31

Now for reasons irelevant to my question the number provided is
hexadecimal. I could ofcourse in the program convert this to a number
but is there a syntax in oracle to use similar to the sql server:
SELECT * FROM table NUM = 0x1F

How do I write this in oracle?

I know I can do a to_num('1F','XX') or something like that but is
there a way to just write a hexadecimal number directly?

Regards Hans Milling...

Hans,

there is no way to express a number in hexadecimal format directly.
This has not changed between at least 8.1.7 and 11.1.
Search the SQL Language Reference provided on
tahiti.oracle.com for "Literals".

Of course there is no need to convert the table data to hexadecimal,
but you do have to convert the hexadecimal representation '1F'
to the type in your table.

HtH,
Urs Metzger

I would suspect you would create a user-defined data type and use
it to build a table that would do this: But why?

As the op clearly states, NUM is a numeric (integer) column, so I would
convert the query parameter '1F' into a number using TO_NUMBER (what else?).

SQL> create table t (num integer);

Tabelle wurde erstellt.

SQL> insert into t values(31);

1 Zeile wurde erstellt.

SQL> select * from t where num = to_number('1F', 'XX');

* * * * NUM
----------
* * * * *31

No need to "convert the table data to hexadecimal".

It's that simple.

Urs Metzger- Hide quoted text -

- Show quoted text -
Thanks for your reply. This is the solution I have chosen to use.


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



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.