Solved

Delphi SQL and Interbase Triggers

Posted on 1997-08-11
2
341 Views
Last Modified: 2010-04-04
Howdy;

It appears that when I do an SQL INSERT from a Query Component with the ExecSQL method, it appears that my BEFORE INSERT Trigger to generate my primary key is not getting triggered... because it gives me an error that I'm trying to insert a NULL primary Key... Any ideas on how to get that to fire off the trigger on INSERT?  (It also doesnt fire off the BEFORE DELETE Trigger!)

Thanks

Roger Webb
0
Comment
Question by:Whytboy
2 Comments
 
LVL 3

Accepted Solution

by:
KE earned 200 total points
Comment Utility
The problem with triggers is that the before/after terms are related to you database server, and not how Delphi handles the transaction. Your database server (or local server) will not insert your record as long as Delphi is holding it back, because of the missing key. What i'm trying to say is that the server is never being told to insert the record as long as the record fails validation in Delphi - and this is the reason for the unfired trigger.
To solve the problem, just insert the key field manually into the dataset, and set the "Required" property to false. After a (hopefully) succesfull insert, you may need to refresh the dataset to get the key field updated.

Kenneth Ellested
0
 

Author Comment

by:Whytboy
Comment Utility
Thanks... sorry it took so long.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

763 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

7 Experts available now in Live!

Get 1:1 Help Now