Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot lookup row in database by UUID RAW(32)

I have the following table:

create table Mike_Test
( Id          raw(32)      default sys_guid() not null primary key,
  Value        varchar2(80) not null unique
);

I now insert into this table:

INSERT INTO Mike_Test (VALUE) VALUES ('Blah');

I can confirm there's a new row in there:

select * from Mike_Test;

And I see:

08364fc81419429d83c9bcedb24a9a57    Blah

Now I try to SELECT that row with:

select * from Mike_Test WHERE ID='08364fc81419429d83c9bcedb24a9a57';

However, I get zero rows and zero errors. What am I doing wrong?

like image 595
Mike Christensen Avatar asked Oct 07 '11 17:10

Mike Christensen


2 Answers

It's a RAW datatype, you have to query like this:

select .... where id=hextoraw('08364fc81419429d83c9bcedb24a9a57') ....
like image 177
Mario Avatar answered Oct 17 '22 17:10

Mario


I think you might need to use the HEXTORAW function around your ID value. This function converts a hex string into the corresponding RAW value.

In other words, your query should look like the following:

select * from Mike_Test WHERE ID=HEXTORAW('08364fc81419429d83c9bcedb24a9a57');
like image 44
Luke Woodward Avatar answered Oct 17 '22 15:10

Luke Woodward