How can I search for a hex string in oracle?
-
22-01-2021 - |
سؤال
There's a database record that is incorrect. The name field displays like this in a browser ( this is incorrect ):
Thcˇodore
And when I look at the record via SQL results, I see:
Thc\xCB\x87odore
I'm trying to search for other records that might be affected, so I would like to query the name
field for any value "LIKE
" \xCB\x87
I've tried using HEXTORAW
and many other combinations including:
REGEXP_LIKE(NAME, \'\xCC\x88\' )
REGEXP_LIKE(NAME, \'[\xCC\x88]\' )
NAME like '%' || HEXTORAW(\'CC88\') || '%'
NAME LIKE ‘%’ || X’CC’ || X’88’ ||’%’
NAME like \'%\' || \'\x88\' || \'%\'
Can't seem to get any of them to work, and I can't find any other examples or documentation online. Maybe I've been googling for the wrong things but this is what I've tried to google:
- oracle escape hexadecimal
- oracle hex to ascii
- oracle like hexadecimal query
- oracle pcre Hexadecimeal select
- oracle query binary character
- oracle REGEXP_LIKE hexadecimal
- oracle select \x0A
- oracle select escape character hex
- oracle select hex codes
- oracle select like \x0a
- oracle select REGEXP_LIKE \x0A
- oracle select X 0A
How can I search for \xCB\x87
with Oracle?
المحلول
SQL> create table t1(c1 varchar2(20 char));
Table created.
SQL> insert into t1 values ('Thcˇodore');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from t1;
C1
--------------------------------------------------------------------------------
Thcˇodore
SQL> select rawtohex(c1) from t1;
RAWTOHEX(C1)
--------------------------------------------------------------------------------
546863CB876F646F7265
SQL> select c1 from t1 where rawtohex(c1) like '%CB87%';
C1
--------------------------------------------------------------------------------
Thcˇodore
SQL>
لا تنتمي إلى dba.stackexchange