display error message if constraint violation

  • Thread starter Thread starter mcnews
  • Start date Start date
M

mcnews

is there a way for the database to display an error message when a
user violates a constraint?
an age limit for example?

tia,
mcnewsxp
 
Not sure but search this newsgroup for the T-SQL function Raiserror.

The problem with Raiserror and other error messages coming from SQL-Server
is that you don't have much control over their display. IMHO, it's much
better to perform all checks yourself; either at the client interface or at
the server using stored procedures.
 
As a programmer, it's your choice but you - and your boss - won't find it
funny if you are ever called on an emergency call to help a new girl/oy who
doesn't understand the half cryptic error messages coming from the server.

You can add limiting constraints on the server if you want to be really sure
that some conditions are fulfilled but IMHO, each error message creeping out
of the server to the user - even if only for a single time - should be seen
as the indication of a bug in your client code.
 
how would you use a stored proc to do it?

Sylvain Lafontaine said:
As a programmer, it's your choice but you - and your boss - won't find it
funny if you are ever called on an emergency call to help a new girl/oy
who doesn't understand the half cryptic error messages coming from the
server.

You can add limiting constraints on the server if you want to be really
sure that some conditions are fulfilled but IMHO, each error message
creeping out of the server to the user - even if only for a single time -
should be seen as the indication of a bug in your client code.
 
Back
Top