Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1042

Re: Enforcing an Order to Validation

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver, microsoft.public.sqlserver.programming
Subject Re: Enforcing an Order to Validation
Followup-To comp.databases.ms-sqlserver
Date 2012-05-11 09:01 +0200
Organization Erland Sommarskog
Message-ID <XnsA0505BC9573FYazorman@127.0.0.1> (permalink)
References <395oq79dfjtpp5b79hdl6vafaikdj449se@4ax.com> <XnsA04FF207A72F6Yazorman@127.0.0.1> <geeoq7dcm51phaejift1bftt99e4q1416r@4ax.com>

Cross-posted to 2 groups.

Followups directed to: comp.databases.ms-sqlserver

Show all headers | View raw


Gene Wirchenko (genew@ocis.net) writes:
>      One of the issues that I have with database errors is the
> disconnect between them and the frontend.  

Yes, down in the database, you cannot really tell what error the user did.
All you can tell is that a constraint etc was violated.

Particularly, if you want error message that helps the user, constraints
are not your guy.

>      I am trying to find out what is the guaranteed behaviour.  That
> is safer.

I gave it some more thinking, and there is hardly any guaranteed order.
There is an optimizer and it makes the actions in the order which is the
most efficient.
 
>      I think that statement should be that the database should never
> permit such, but the application should be free to do no error
> checking.  The application also doing error checking makes for a more
> friendly app, but I would prefer correctness FIRST.
 
Let me make it clear again: the error messages that are produced by 
SQL Server when a constraint is violated are not helpful for the user.
At best you can trap and interpret them. But that is difficult.

And since the error messages are useless to the user, it's completely
irrelevant in which order SQL Server checks the constraints.

Error messages from stored procedures and trigger checks are a different
matter, here you have control. Then again, down in the trigger all
you can tell that a column has an illegal value, but you don't know
where in the form the user went wrong. You don't even know if there is
a form.

Finally, permit me to point out that the application can implement error 
checking more than one way. If a column only permits the values A, B and C 
the application will of course not expose a text box, but a drop-down or a 
ratio button.

-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Enforcing an Order to Validation Gene Wirchenko <genew@ocis.net> - 2012-05-10 12:42 -0700
  Re: Enforcing an Order to Validation Erland Sommarskog <esquel@sommarskog.se> - 2012-05-10 23:47 +0200
    Re: Enforcing an Order to Validation Gene Wirchenko <genew@ocis.net> - 2012-05-10 15:05 -0700
      Re: Enforcing an Order to Validation Erland Sommarskog <esquel@sommarskog.se> - 2012-05-11 09:01 +0200
        Re: Enforcing an Order to Validation Gene Wirchenko <genew@ocis.net> - 2012-05-11 09:50 -0700
          Re: Enforcing an Order to Validation Erland Sommarskog <esquel@sommarskog.se> - 2012-05-11 22:29 +0200
            Re: Enforcing an Order to Validation Gene Wirchenko <genew@ocis.net> - 2012-05-11 22:10 -0700

csiph-web