my dog learned polymorphism*
The moose likes JDBC and the fly likes SQL Query to retrieve the RAW datatype from the Oracle DB Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "SQL Query to retrieve the RAW datatype from the Oracle DB" Watch "SQL Query to retrieve the RAW datatype from the Oracle DB" New topic
Author

SQL Query to retrieve the RAW datatype from the Oracle DB

Shincy Cherian
Greenhorn

Joined: Jul 02, 2012
Posts: 3
HI All,
I need help to form a SQL query to retrieve RAW datatype column values from Oracle DB.
I should be able to get the value from the query in String format. If you have come across this kind of scenario, please let me know.
I would like to know how to get this String value in Java.

-Thanks.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

I have done a quick search and a RAW datatype is not a string it is binary data, pre-cursor to BLOBS (well LONG RAW is).
So why do you want it in a String?
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

and welcome to the ranch
Shincy Cherian
Greenhorn

Joined: Jul 02, 2012
Posts: 3
Hi Wendy,
Thank You for the response. I needed it in string format so that I could do some kind of manipulation on the data.

I am using Java as the front end and based on the data that I have recieve from the database I need to do some manipulation.

Also in the where clause I want to specify a column value which is basically a string value

For eg my query would be as simple as follows:
Select column1 from table1 where column2='test';

I think I may need to convet this value "test" as hex inorder to use it in the where clause in the select.. How can I convert a string data to "hex" ?

Am I going in the right track ?

Please let me know.
-Thanks.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

I found this quote on oracle docs

When Oracle automatically converts RAW or LONG RAW data to and from CHAR data, the binary data is represented in hexadecimal form, with one hexadecimal character representing every four bits of RAW data. For example, one byte of RAW data with bits 11001011 is displayed and entered as CB.


so you are on the right track (I am learning this as I go).

this stack overflow discussion talks about converting text to binary.
string to binary

but of course there is a chance oracle will not let you do an = on a RAW column.
Have you tried that out first just using any rubbish?

I found this on another website: sorry I can't tell you which one as they apparently publish lots of naughty stuff as well.

insert into raw_raw values (1, rawtohex('AAABBB'))


I know it isn't an exact answer but it points out there may be an oracle function to help you?

and finally on page 3
even more random website

well I suppose I had better do some work now, although not sure what as the login screen has been accidentally disabled
Shincy Cherian
Greenhorn

Joined: Jul 02, 2012
Posts: 3
Hi Wendy,
Thank you for the response again and I really appreciate your response.....

You are right!! thanks for checking this for me .......

I have found a resolution, we can use the funtion RAWTOHEX in our Select Queries ....

-Again thanks for your responses and your help.

-Thanks.
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

your welcome
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: SQL Query to retrieve the RAW datatype from the Oracle DB