Solved

custom message in constraint fail in SQL

Posted on 2003-11-14
6
203 Views
Last Modified: 2012-06-22
welll sorry experts for assigning less points!!!!i don't have the points.

i have foll questions like:

1. I have added a constrainst in my table on one field. Now when i am trying to insert the records(which violates the constrainst) an error message is generated. Now can i custmize this error message.

2. For some other table I am raising the error message insidde a trigger using raiserror command. Is it possible to raise a message instead of an error message. Inside my application, it shows only the OK button. Is it possible to send a message with YES/NO button. As far as i know it is not possible. Just to confirm it.

3. The reason why i am doing all this is because our client has brought a package from outside agency. Now we have got the responsibility to add business logic in this package thry Backend(SQL) using triggers etc. Are there any other ways i can implement busiess logic in this application.

I know i have very less points. As soon as i will get more points i will keep on adding!!!
0
Comment
Question by:pg_india
  • 3
  • 2
6 Comments
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 9752970
Please maintain your many old open questions:

1 03/20/2003 50 CD KEY INSTALLATION  Open Windows Security
2 03/22/2003 50 CRYSTAL REPORT  Open Crystal Reports
3 09/09/2003 100 CRYSTAL REPORT/ASP  Open Crystal Reports
4 07/05/2003 70 FLASH DOWNLOAD ICON  Open Macromedia Flash
5 08/05/2003 70 SNMP SERVICE  Open VB Controls
6 08/27/2003 100 NETWORK BANDWIDTH THRU VB  Open Networking
7 09/30/2003 75 HOW TO USE GETPIXEL  Open Visual Basic

Thanks,
Anthony
0
 
LVL 34

Expert Comment

by:arbert
ID: 9753067
You cannot customize the constraint error messages.  Generally, you capture the errors in your front-end application and re-display the errors as something meaningful to your client.


"2. For some other table I am raising the error message insidde a trigger using raiserror command. Is it possible to raise a message instead of an error message. Inside my application, it shows only the OK button. Is it possible to send a message with YES/NO button. As far as i know it is not possible. Just to confirm it.
"

What  are you using to create your application?  You should be able to present the user with a form or message box that contains Yes/No....
0
 
LVL 3

Author Comment

by:pg_india
ID: 9753224
Thanks Albert for your help and acperkins yes i am closing my old question.Don't worry abt it.See i have increased the points by 100.

Basically its a exe which we have got from third party. So weccont change anythg in it. Should i assume then that it is not possible from SQL Server.

Also i want to know:
Are there any other ways i can implement busiess logic in this application??

Any help will be apprecirated.


0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 34

Expert Comment

by:arbert
ID: 9753250
So if you can't change the application, how would you possibly change the business logic in it?????

If you can't change the application, it pretty much becomes a training issue--that's the way it is and you just train your users to get use to it.

Can you request the vendor make more descriptive error messages?

Brett
0
 
LVL 3

Author Comment

by:pg_india
ID: 9753295
i understand that but usiness logic can be implemented at SQL level also. Not 100% but we can do some validations etc etc. Now i want to know various ways of doing that through SQL as the application is able to handle SQL errors and display them.

An example is suppose i don't want user to enter age in negative in table "customer" lets say age field. Now i can write a trigger on customer where i can do validation that if age <=0 then raiseerror with some error number and the application is able to show that error. This much i have completed but i need to know if there any other ways of doing the same. Can i send some message also instead of the error message!!!
0
 
LVL 34

Accepted Solution

by:
arbert earned 120 total points
ID: 9754736
Nope, you're stuck with the sql errors....Also, instead of the trigger--use a constraint--best practice.....

Personally, if I had to code a bunch of extra logic on the backend to handle stuff like that--I would be searching for a different front end.....
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now