Solved

custom message in constraint fail in SQL

Posted on 2003-11-14
6
204 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
email the result out from a T-SQL queries 29 62
Error when loading the database 16 55
ASP.NET 5 Templates 2 65
SQL Server stored proc 2 12
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
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.

911 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

18 Experts available now in Live!

Get 1:1 Help Now