?
Solved

AddNew and Update Methods

Posted on 2000-04-20
3
Medium Priority
?
310 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 60 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month8 days, 12 hours left to enroll

765 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