Skip to Main Content

SQL & PL/SQL

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!

Conditional Check Constraint for BLOB column in Oracle 19C

Hgnis-OracleJun 15 2023

I have a table with a BLOB column. I have NOT NULL constraint on the same BLOB column. I want to allow nonempty files to be inserted into the column only. Now, NN constraint does not help to check the empty file. It allows both valid file and empty file into it.

How can I restrict to empty files being inserted into the BLOB column?

We are using Oracle 19c.

I tried with creating a CHECK constraint something like this. But it failed. I got an invalid identifier error - dbms_lob.getlength.

ALTER TABLE tb_name
ADD CONSTRAINT cons_name
CHECK(dbms_lob.getlength("col_name")>0);

Share your inputs and suggestions.

Thanks.

This post has been answered by Stax on Jun 15 2023
Jump to Answer
Comments
Post Details
Added on Jun 15 2023
22 comments
956 views