On Tue, 22 May 2012 07:27:13 +0000 (UTC), Erland Sommarskog
Post by Erland SommarskogPost by Gene WirchenkoIf a constraint of some sort is violated, how can I find out
which one?
Yes, I can parse the error message hoping to find it, but, as
pointed out by Erland, that is subject to the error message being
changed. I prefer to avoid kludges.
Is there a function that returns this value?
Anyone for an error_constraint() function?
You can always try to raise your voice on
http://connect.microsoft.com/SqlServer/FeedBack
It helps if you can explain this from a business perspective.
"try" is the word. Apparently, a Windows Live id is required and
one has already been created for my E-mail address. I might have
tried to create one years ago and had it fail somehow.
Post by Erland SommarskogBut for now, you will have to parse the error message. You can stick it into
a function, so if the message is changed in a futre version of SQL Server,
you only have to change the function.
That will be a lot of work going through the various, possible
related errors, but I suppose it will have to do.
Since I can not post to the feedback, could you please post the
following on my behalf?
***** Start of Feedback *****
Dear SQL Server Feedback:
0) Requiring a Windows Live id account in order to post is rather
unfriendly. I have not been able to get one set up. Or rather,
apparently, I did set one up, but it does not work. An alternative
way, such as E-mail, would be a good idea. This is being posted on my
behalf.
1) I am developing an application that will use SQL Server. Because
I want a friendly application and I want validated data, I want to
have db constraints. There are some complications.
First, I want to be able to detect which constraint failed so I
can return an appropriate return code so that I can set focus
appropriately in the front-end. I suggest a function
error_constraint() which would return the name of the constraint that
failed. Currently, I am going to have to write a function to parse
the relevant error messages. This will be prone to breaking should
you change the error messages.
Second, there is no defined order (that I know of) for the order
of checking of the constraints. I would like them to fire in an order
that makes sense to my front-end. I realise that many will not care
about the order and consider speed more important. I am fine with it
defaulting to optimise for speed, but I would like to be able to
specify the order.
Sincerely,
Gene Wirchenko
***@ocis.net
***** End of Feedback *****
Sincerely,
Gene Wirchenko