Ravindra
Ravindra

Reputation: 61

Is there any easy way to remove not null constraints of table based on a condition

If mty.bty_tp = GA and mty.geal_conds_vion_num like %36% then the mandatory input(not null constraints) in various tables should disabled.

It concerns the following tables

· tbt_con.entry_dat

· tbt__texts

· tbt_amounts

· tbmt_currencies

Upvotes: 0

Views: 51

Answers (1)

Littlefoot
Littlefoot

Reputation: 142733

You can't do that, not conditionally as a constraint ("as is").

In order to enforce that, you'll need to either

  • use a database trigger which will allow (or not) you to insert NULL values into certain columns
  • implement that in front-end application

I guess that the 1st option is "safer" as you don't have to take care about it afterwards - database will prevent invalid inserts.

It also means that columns in those tables should NOT be created as NOT NULL.

Upvotes: 1

Related Questions