Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

oracle raw datatype in where clause

Tags:

sql

oracle

I have a column of RAW type in my database. How can I use it in where clause?
i.e to get only values with third byte equal to 4.
this does not work:

SELECT v from T where v[3]=4
like image 410
Roman Avatar asked Jun 23 '10 12:06

Roman


People also ask

What does raw datatype in Oracle?

RAW. The RAW datatype is used for binary data or byte strings that are not to be interpreted by Oracle, for example, to store graphics character sequences. The maximum length of a RAW column is 2000 bytes.

Is Raw a datatype in SQL?

In Oracle PL/SQL, RAW is a data type used to store binary data, or data which is byte oriented (for example, graphics or audio files). One of the most important things to note about RAW data is that it can only be queried or inserted; RAW data cannot be manipulated.

Can we use column alias in where clause Oracle?

Standard SQL disallows references to column aliases in a WHERE clause. This restriction is imposed because when the WHERE clause is evaluated, the column value may not yet have been determined.

Which datatype is used to store binary value CLOB BLOB raw long?

You use the LONG RAW datatype to store binary data or byte strings.


2 Answers

in Oracle : you can use HEXTORAW function

  • select * from TBLTest01 where (BINCOL=hextoraw('f0f0f3') )

it is in other databases in another way. for example in DB2 :

  • select * from TBLTest01 where BINCOL=BINARY(x'F0F0F3')
like image 192
afshar Avatar answered Sep 21 '22 13:09

afshar


use the functions of the UTL_RAW package to interact with raws, for example:

SQL> create table test (a raw(16));

Table created

SQL> insert into test values ('FF00FF00FF');

1 row inserted

SQL> select * from test where utl_raw.substr(a, 3, 1) = 'FF';

A
--------------------------------
FF00FF00FF
like image 28
Vincent Malgrat Avatar answered Sep 19 '22 13:09

Vincent Malgrat