I would like to use ORA_HASH on xmltype datatype, and workarounds are straight forward solutions ?
I am using oracle 11g r2 and binary xml as storage option for xmltype column
Query which I used for creation of the table is
create table samplebinary ( indexid number(19,0) , xmlcolumn xmltype not null) xmltype column xmlcolumn store as binary xml;
As you already know,
ora_hash
doesn't acceptlong
or LOB values. You could pass in the first 4k or 32k of the XML content, but if you need to make sure that the entire XML document hasn't changed, that won't be sufficient. And as Ben mentioned,ora_hash
has a maximum of 4294967295 buckets, so collisions are rather more likely than with SHA-1 or MD5. As the documentation says,ora_hash
'is useful for operations such as analyzing a subset of data and generating a random sample'.You can use the
dbms_crypto
package to hash the whole XMLType value, as a CLOB extracted with thegetClobVal
function, with a wrapper function to make it simpler to use:You can then pass in your XMLType, as a value or as a column as part of a select: