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
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.
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.
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.
You use the LONG RAW datatype to store binary data or byte strings.
in Oracle : you can use HEXTORAW function
it is in other databases in another way. for example in DB2 :
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With