Is there a more concise syntax for checking whether multiple columns are not null? I'm looking to simplify
weight IS NOT NULL AND
weight_unit IS NOT NULL AND
length IS NOT NULL AND
width IS NOT NULL AND
height IS NOT NULL AND
dimensional_unit IS NOT NULL
into something shorter.
Using Oracle, if it's relevant.
Depending on the privilege, you need to look into [DBA|USER|ALL]_TAB_COLUMNS. ALL_TAB_COLUMNS Column Datatype Description NULLABLE VARCHAR2(1) Indicates whether a column allows NULLs. The value is N if there is a NOT NULL constraint on the column or if the column is part of a PRIMARY KEY.
With De Morgan's law:
NOT (A OR B) = (NOT A) AND (NOT B)
you save 20 chars ;)
NOT (
weight IS NULL OR
weight_unit IS NULL OR
length IS NULL OR
width IS NULL OR
height IS NULL OR
dimensional_unit IS NULL
)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With