Solved

AddNew and Update Methods

Posted on 2000-04-20
3
305 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
[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
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

730 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