Skip to content
Advertisement

Oracle-SQL How to check dates before inserting

I have a simple insert statement like below

where validFrom and validTo have a DATE type.

I want to insert records to table only if validFrom <= validTo. How can I add some condition checking to the SQL statement to do so? For now I’m doing the cheking with java and I want to do it in the sql query if possible.

EDIT

Advertisement

Answer

You can add a check constraint:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement