Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Deleting & database triggers

Posted on 1997-12-08
7
Medium Priority
?
192 Views
Last Modified: 2010-04-04
I have a table, with a trigger on it wich prevents certain deletes.
A Delphi program tries to delete a record, but the trigger prevents it from being deleted. However, my delphi progam doesn't show the record anymore, unless i do a refresh. Is there an OTHER way (so without me doing a refresh) to keep on seeing that record ?
0
Comment
Question by:jvh042097
[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
7 Comments
 

Expert Comment

by:brendanmc
ID: 1353084
Try adding some type of code into your trigger that forces a refresh when the trigger is triggered.... This way it will automatically refresh.
0
 

Author Comment

by:jvh042097
ID: 1353085
If this is the type of answer an expert gives, i'm also an expert. How can i get my SQL forcing a refresh of my Delphi Datasource ?

But i'd rather like my Delphi recognize the fact that the record still exists !

Hoping for a real answer !
0
 
LVL 3

Expert Comment

by:altena
ID: 1353086
(Anyone who can point a browser to this site can probably
register as an expert too...)

Anyway for my real answer:

I do not know that database server you use but normally
your "Delete from ..." SQL will generate some sort of
error message when you execute it. (Although common sense suggests that you should receive an error message whenever the
delete fails...)

You should execute the SQL by hand and see what happens if
the trigger prevents the delete. If there is no error, you
have a problem at the server side (IMHO)

If there is an error, then you can catch that error in your code
and you bnever have to refresh in the first place.

  Good Luck,

(And please, please please use the TSQL component,)
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:jvh042097
ID: 1353087
Isn't TSQL part of oracle ? I use M$ $QL$ERVER !

if a trigger does a rollback of the transaction, there is no real error occuring. It's just part of the business rules, that you can't delete a specific record. In MS SQLServer, Stored procedures can return a kind of status level, but triggers cannot. So i keep on looking for a solution ...
0
 
LVL 3

Accepted Solution

by:
Pegasus100397 earned 400 total points
ID: 1353088
Jeez... almost to simple to warrant an answer, but here goes anyway...

If the trigger causes a rollback (failed delete) then INSIDE the trigger issue a RAISERROR statement that you can capture with Delphi to indicate that yes, the delete was *attempted* but it failed due to a business rule conflict. When you issue the RAISEERROR statement try and use an error code that is not normally in use by MS SQL Server but is meaningful in the context of your application/business rules.

When Delphi recieves anything other than a successful completion code (0) back from the server it assumes there was a failure of that operation (be it Update, Delete or Insert) and WILL NOT remove that record from the result set on the client side.

The apps I'm working with do this on a regular basis, it's part of standard SQL knowledge in regard to client/server architecture :P

Good luck with your project
Pegasus
0
 

Author Comment

by:jvh042097
ID: 1353089
Sorry, but i also came to this so simple answer to my "stupid" question. Thanks alot anyway !!!
0
 
LVL 3

Expert Comment

by:Pegasus100397
ID: 1353090
Jvh,

It was not a "stupid" question at all, just one that I assumed everyone was familiar with how to handle. Bad assumption on my part. Anyways, glad to see everything is working ok.

On to the next bug! :)
Pegasus
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

670 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