Solved

custom message in constraint fail in SQL

Posted on 2003-11-14
6
208 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Suggested Solutions

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…
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…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

734 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