Solved

custom message in constraint fail in SQL

Posted on 2003-11-14
6
205 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Query Syntax 17 36
SQL Server 2015 Restore - doing it right 2 15
horizontal scale out 29 15
How to make a stored procedure return two values 5 12
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

832 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