Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What is the best way to do table-level validation on column values ?

0
10 Posted

What is the best way to do table-level validation on column values ?

0

Database procedures called from database triggers are often a better way to do table-level validation on column values than using check constraints. You can easily perform most validation with a check constraint because it can use a database function as part of its SQL expression. However, check constraints are not a normal place to look for code; if someone tries to determine where validation is firing for a column, she or he may not find that code easily. In addition, you can do operations in a procedure that might not be possible with a function that has SQL restrictions. For example, writing a record to an audit table if validation failed is straightforward in a database procedure called by a trigger but may not be possible using a function in a check constraint.

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.