Solved

AddNew and Update Methods

Posted on 2000-04-20
3
301 Views
Last Modified: 2010-05-02
Is it possible to fire a trigger on an Oracle database using the .AddNew and .Update methods or do you have to use INSERT - SQL statements.

Cheers...
0
Comment
Question by:DarrenD
  • 2
3 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 2734090
The trigger should fire regardless of the method used to actually insert the data. As far as the Oracle DB is concerned, data has been inserted into the table and the appropriate trigger(s) will be fired. The .AddNew and .Update methods merely provide a mechanism to handle the creation of an implicit INSERT statement.
0
 

Accepted Solution

by:
mbkurtz earned 20 total points
ID: 2738408
When you call .AddNew in your VB code, Oracle will not fire any triggers.  This is because the new record is not actually added to the database until the .Update method is called.  
However, Oracle does have BEFORE INSERT and AFTER INSERT triggers that fire when .Update is called.  Since the before insert trigger is fired before the new record is added, you can use it to do any validation or anything you may have wanted to do when the .AddNew method was called.  It is also a great place to populate a PK field with a value from a sequence.
Once the record has been added to the database, the after insert trigger will fire.
0
 

Expert Comment

by:mbkurtz
ID: 2743903
mbkurtz changed the proposed answer to a comment
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

22 Experts available now in Live!

Get 1:1 Help Now