Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Hash value and virtual column as a primary KEY

BeefStuDec 8 2021

I have the following table, where I would like the value of hash_val to be generated from clob_val whether clob_val is inserted or updated.
Can this be done perhaps by making the column hash_val a virtual column? Or does this have to be done via a function and trigger.
I want to use something like the CRYPTO call below to generate the value for hash_val. In addition, I would like hash_val to be the primary KEY
Any examples setting up the virtual column if possible would be greatly appreciated. Thanks to all who answer.


CREATE table table_z(
seq_num integer  GENERATED BY DEFAULT AS IDENTITY (START WITH 1) NOT NULL,
val NUMBER, 
hash_val VARCHAR2(1000), 
clob_val CLOB);

DBMS_CRYPTO.HASH (clob_val, 6                          /*DBMS_CRYPTO.HASH_SH512*/                                              )
This post has been answered by Solomon Yakobson on Dec 9 2021
Jump to Answer
Comments
Post Details
Added on Dec 8 2021
4 comments
1,484 views