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!

DEFAULT CONSTRAINT with CASE STATEMENT -- Oracle 11.2.0.3

Kevin_KJul 29 2014 — edited Jul 29 2014

Is it possible to create a default constraint on a table based on some conditional logic.

For example:

CREATE TABLE TEST_T( DEPT_NO NUMBER,

                                      GRANT_FL CHAR(1)

);

DEPT_NO GRANT_FL

10             Y

10             Y

0               N

I want the DEPT_NO to be populated with a default value of 10 only when GRANT_FL = 'Y' Otherwise Set it to 0.

I can do this with a After Insert Trigger but would be better if this can be done via case statement which sets a default value.

Thanks Much!

Kevin

This post has been answered by Frank Kulash on Jul 29 2014
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 26 2014
Added on Jul 29 2014
3 comments
646 views