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!

check constraint with case statement

user650888May 4 2017 — edited May 4 2017

I have a table with partition and sub partition, I want to apply a check constraint on the sub partition column, i am not sure why my case statement is failing with "[Error] Execution (20: 1): ORA-00920: invalid relational operator"

CREATE TABLE test2

(

my_date date,

mypos varchar2(100),

chk_flag varchar2(1)

)  TABLESPACE system

    PARTITION BY RANGE (my_date)  INTERVAL (NUMTODSINTERVAL(1,'DAY'))

     SUBPARTITION BY LIST (chk_flag) 

      SUBPARTITION TEMPLATE(

    SUBPARTITION P_ISO     VALUES ('Y') TABLESPACE system,

    SUBPARTITION P_NON     VALUES ('N') TABLESPACE system

   

                )                  

               (PARTITION my_example VALUES LESS THAN (TO_DATE('01-JAN-2012','DD-MON-YYYY')));

               alter table test2 add constraint chk_fl

CHECK ( CASE WHEN mypos = 'MANAGER' THEN 'Y' ELSE 'N' END

)

Also, my understanding is, going for a constraint is better than a trigger since trigger slows down the inserts and selects, am I correct ?

This post has been answered by Frank Kulash on May 4 2017
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 1 2017
Added on May 4 2017
15 comments
3,028 views