Does a Insert trigger fire when the insert is committed?

I'm curious, does a Insert trigger fire when the insert is committed? If you could point to an article as well that would be great !
Thanks,
Dman780

Its depends of FOR | AFTER
FOR | AFTER
AFTER specifies that the DML trigger is fired only when all operations specified in the triggering SQL statement have executed successfully. All referential cascade actions and constraint checks also must succeed before this trigger fires.
AFTER is the default when FOR is the only keyword specified.
AFTER triggers cannot be defined on views.
For mor information : http://technet.microsoft.com/en-us/library/ms189799.aspx

Similar Messages

  • SELECT * cannot be used in an INSERT INTO query when the source or destination table contains a multivalued field

    Hi,
    I am using Access 2013 and I have the following VBA code, 
    strSQL = "INSERT INTO Master SELECT * from Master WHERE ID = 1"
     DoCmd.RunSQL (strSQL)
    when the SQL statement is run, I got this error.
    SELECT * cannot be used in an INSERT INTO query when the source or destination table contains a multivalued field
    Any suggestion on how to get around this?
    Please advice and your help would be greatly appreciated!

    Rather than modelling the many-to-many relationship type by means of a multi-valued field, do so by the conventional means of modelling the relationship type by a table which resolves it into two one-to-many relationship types.  You give no indication
    of what is being modelled here, so let's assume a generic model where there is a many-to-many relationship type between Masters and Slaves, for which you'd have the following tables:
    Masters
    ....MasterID  (PK)
    ....Master
    Slaves
    ....SlaveID  (PK)
    ....Slave
    and to model the relationship type:
    SlaveMastership
    ....SlaveID  (FK)
    ....MasterID  (FK)
    The primary key of the last is a composite one of the two foreign keys SlaveID and MasterID.
    You appear to be trying to insert duplicates of a subset of rows from the same table.  With the above structure, to do this you would firstly have to insert rows into the referenced table Masters for all columns bar the key, which, presuming this to be
    an autonumber column, would be assigned new values automatically.  To map these new rows to the same rows in Slaves as the original subset you would then need to insert rows into SlaveMastership with the same SlaveID values as those in Slaves referenced
    by those rows in Slavemastership which referenced the keys of the original subset of rows from Masters, and the MasterID values of the rows inserted in the first insert operation.  This would require joins to be made between the original and the new subsets
    of rows in two instances of Masters on other columns which constitute a candidate key of Masters, so that the rows from SlaveMastership can be identified.
    You'll find examples of these sort of insert operations in DecomposerDemo.zip in my public databases folder at:
    https://onedrive.live.com/?cid=44CC60D7FEA42912&id=44CC60D7FEA42912!169
    If you have difficulty opening the link copy its text (NB, not the link location) and paste it into your browser's address bar.
    In this little demo file non-normalized data from Excel is decomposed into a set of normalized tables.  Unlike your situation this does not involve duplication of rows into the same table, but the methodology for the insertion of rows into a table which
    models a many-to-many relationship type is broadly the same.
    The fact that you have this requirement to duplicate a subset of rows into the same table, however, does make me wonder about the validity of the underlying logical model.  I think it would help us if you could describe in detail just what in real world
    terms is being modelled by this table, and the purpose of the insert operation which you are attempting.
    Ken Sheridan, Stafford, England

  • Macbook Pro 2011 DVI HDMI out does not work with TV when the power cable is connected

    My Macbook Pro (Early 2011) DVI HDMI out does not work with TV when the power cable is connected. If get the blue screen and then can use the macbook but nothing is displayed on the TV. If i go into display I can see that there are two screens but nothing displayed on the TV. If i take the power cable out at this point the TV shows the second desktop as expected. If i then reconnect the cable, the screen flickers, as though it is being affected by the power cable, and the screen goes blank on the TV. Only if i remove the DVI cable do i get the blue screen again. If i remove the power cable and reconnect it will do it every single time, so i cannot see it being a TV issue or a minor glitch.
    I have had this working previously but at the minute it seems to not be playing ball....any thoughts
    Thanks
    Dan

    BUMP
    Any ideas?

  • How does c:url tag know when the session is cookieless and thus to redirect

    i have been looking at the source code for c:url tag and can't figure out how they are doing that. I need a way to do that in a jsp, to check if the cookies are allowed or not.

    how does c:url tag know when the session is cookieless and thus to redirecthuh?
    What do cookies have to do with redirecting?
    Cookies get encoded into a URL using the method in HttpServletResponse: response.encodeURL() or encodeRedirectURL().
    That method determines whether or not it prints out the session id as part of the url, or it gets uses cookies.
    You can try: request.isRequestedSessionIdFromCookie().
    If that is true, you know that session cookies are supported (or at least that one was)

  • Why does message show as sent when the user is off...

    Why does message show as sent when the user is offline??
    After merging my Facebook and msn, I've been told by my Skype contacts, that whenever I'm offline, and they message me, it shows that I got the message. Just like I'm online.
    This is also happening to my other friends who have merged their accounts ;(....!!!!
    Please help, please! ;(...!!! I'm not hacked, I know, but it's happening even with other people who have merged the ACC....

    Hello Colin,
    The issue that you are describing is in fact a feature. You can learn more about the benefits of this feature by viewing the following  article: http://support.apple.com/kb/HT3679
    Spencer R
    AppleCare

  • Does anyone have an idea when the new version of apple tv is coming out?

    does anyone have an idea when the new version of apple tv is coming out? I want to buy apple tv, but would prefer to wait if it is expected to come out in the next month or so.

    No, as this is a user forum and speculation is not permitted.

  • SQL Query to find when the data was committed

    Hi,
    In oracle how do we find the when the row as committed into DB(Timestamp):
    Eg:
    If insert 1000 records from the application i want to know what is exact time the data was committed in the DB.
    Regards
    NM

    NM wrote:
    Hi,
    Thanks for your Input.
    The Query returned the following.But I want something like this 7/6/2011 6:43:54.23:32:00000 PM(Includes micro seconds)
    SELECT ora_rowscn,orderid FROM tibex_order  where orderid='0NEC.000OXNVE9JYSNQC' ;
    12541143230,0NEC.000OXNVE9JYSNQC
    SELECT SCN_TO_TIMESTAMP(ORA_ROWSCN) FROM tibex_order where orderid='0NEC.000OXNVE9JYSNQC' ;
    7/6/2011 6:43:54.000000000 PMRegards
    NMIt's already giving it to you in nano-seconds.
    What's with this format:???
    But I want something like this 7/6/2011 6:43:54.23:32:00000 PM
                                            ^ ^  ^  ^^^
                                            | |  |  ||+-- what is this colon for?
                                            | |  |  |+--- hundredths of seconds
                                            | |  |  +---- tenths of seconds
                                            | |  +------- seconds
                                            | +---------- minutes 
                                            +------------ hour

  • What's the exact trigger for when updating/inserting/deleting data from one DB to another DB which contains same info?

    Hi guys,
    I have created a copy of the AdventureWorks2012 DB called AdventureWorks2012_new on the same instance.
    I have created the following trigger below but my friend who is a DBA told me that this is not correct and I should be using the inserted table when creating this trigger. I would like AdventureWorks2012_new DB to be updating/inserting/deleting data from
    the same tables that have been updated/inserted/deleted in the AdventureWorks2012 DB. How exactly should I do this for all the tables in the whole database ? What I have written below is just for one of the tables, is there a quicker way to do it for all tables
    in this DB so that it performs the actions mentioned above, automatically ? Help would be greatly appreciated so I can understand how this works, thanks
    CREATE TRIGGER [HumanResources].[tr_HumanResources_AfterUpdate]
    ON [AdventureWorks2012].[HumanResources].[Department]
    AFTER UPDATE
    AS
    BEGIN
    SET NOCOUNT ON;
    UPDATE AdventureWorks2012_new.HumanResources.Department
    SET Name = t2.Name,
    GroupName = t2.GroupName,
    ModifiedDate = t2.ModifiedDate
    FROM AdventureWorks2012.HumanResources.Department AS t2
    INNER JOIN AdventureWorks2012_new.HumanResources.Department AS t1
    ON t2.DepartmentID = t1.DepartmentID
    END

    For insert it's easy:
    CREATE TRIGGER [HumanResources].[tr_HumanResources_AfterInsert]
    ON [AdventureWorks2012].[HumanResources].[Department]
    AFTER INSERT
    AS
    BEGIN
    SET NOCOUNT ON;
    Insert INTO AdventureWorks2012_new.HumanResources.Department
    (DepartmentID, Name, GroupName, ModifiedDate)
    SELECT DepartmentID, Name, GroupName, ModifiedDate
    FROM Inserted;
    END
    I didn't verify column names, so you may need to make sure to use correct column names for that table.
    Setting replication is a bit advanced topic although BOL is clear and you may start here
    http://technet.microsoft.com/en-us/library/ms151198.aspx
    If it will be complicated for you, you can ask extra questions in the MSDN Replication forum.
    For every expert, there is an equal and opposite expert. - Becker's Law
    My blog
    My TechNet articles

  • Would it be faster to use a trigger or modify the insert query?

    We have a table that currently has latitude, longitude columns and are trying to decide what route to go as far as adding spatial data to future records. A spatial index will be placed on the new column.
    There appear to be 3 solutions:
    1 Create a materialized view which creates the spatial column based on the current latitude and longitude columns.
    2 Create a trigger on the table that will populate the new spatial column on insert/update.
    3 Modify the code to insert a spatial value into the new spatial column.
    Due to the nature of the data we are not willing to use method 1.
    What we are trying to figure out is which method, 2 or 3, will insert faster.
    Has anyone done tests to determine if an insert with a spatial object is slower than an insert on a table with a trigger that creates a spatial object?
    Thanks,
    Pat

    Pat,
    Note that you don't need to store latitude, longitude in sdo_geometry type in order to spatially index it. Instead you can create a function that returns an sdo_geometry based on two numeric columns, then create a function based index on that. Its described here:
    http://download.oracle.com/docs/cd/E11882_01/appdev.112/e11830/sdo_exten.htm#i1005799
    Also note that in the sdo_geometry type, you need to define the data as longitude/latitude and not the other way around.
    If you do want to create a column with sdo_geometry column, I'd recommend your third option. As a general principle I avoid triggers unless absolutely necessary. Triggers invariably lead to confusion when you (or someone else) revisits this code in the future. Also the change of context between and SQL and PL/SQL has a performance hit. Here's a simple test:
    SQL> CREATE TABLE long_lat_no_trigger (
      2     geometry                SDO_GEOMETRY);
    Table created.
    SQL>
    SQL> CREATE TABLE long_lat_with_trigger (
      2     longitude               NUMBER,
      3     latitude                NUMBER,
      4     geometry                SDO_GEOMETRY);
    Table created.
    SQL>
    SQL> CREATE OR REPLACE TRIGGER long_lat_to_geometry
      2  BEFORE INSERT ON long_lat_with_trigger FOR EACH ROW
      3  DECLARE
      4  BEGIN
      5     :new.geometry := SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(
      6     :new.longitude, :new.latitude, NULL), NULL, NULL);
      7  END;
      8  /
    Trigger created.
    SQL>
    SQL> SET TIMING ON
    SQL> INSERT INTO long_lat_no_trigger (geometry) (
      2     SELECT
      3     SDO_GEOMETRY(2001, 8307, SDO_POINT_TYPE(
      4     dbms_random.value(0,180), dbms_random.value(0,90),
      5     NULL), NULL, NULL)
      6     FROM DUAL
      7     CONNECT BY LEVEL <= 1000000);
    1000000 rows created.
    Elapsed: 00:00:31.96
    SQL>
    SQL> INSERT INTO long_lat_with_trigger (longitude, latitude) (
      2     SELECT
      3     dbms_random.value(0,180),
      4     dbms_random.value(0,90)
      5     FROM DUAL
      6     CONNECT BY LEVEL <= 1000000);
    1000000 rows created.
    Elapsed: 00:01:21.15Cheers,
    John

  • Insertion time doubles when the cache is distributed on more than 3 nodes

    Hi,
    I am running some tests where I am persisting 1,000,000 person objects in the cache in batch of 500 objects(using putAll). Prior to the insertion of each batch, we fetch the previous version of the person(using getAll) already in the cache to do some operations with the persons that we want to insert (very basic operations).
    Then we insert the new version of the objects in the cache. (the objects and all their previous versions remain in the cache).
    The cache is a distributed cache and the objects are serialized using the POF format. In the map, the key is the person SSN + version number and the value the person itself. There are indexes on the person SSN and on the version number.
    I notice that when I run the test with the cache distributed on 2 nodes, I have a throughput of 1,400 inserted objects per second.
    The throughput is the same with the cache distributed on only one node.
    However if the cache is distributed on 3 nodes or more, the insertion throughput decreases to 700 objects per second.
    In my configuration, I uses a distributed-scheme with a com.tangosol.util.SafeHashMap for the backing map.
              <distributed-scheme>
                   <scheme-name>persons</scheme-name>
                   <service-name>DistributedCache</service-name>
                   <backing-map-scheme>
                        <class-scheme>
                             <scheme-ref>default-backing-map</scheme-ref>
                        </class-scheme>
                   </backing-map-scheme>
                   <serializer>
                   <class-name>com.tangosol.io.pof.ConfigurablePofContext</class-name>
                   <init-params>
                   <init-param>
                   <param-value>pof-config.xml</param-value>
                   <param-type>String</param-type>
                   </init-param>
                   </init-params>
                   </serializer>
              </distributed-scheme>
              <class-scheme>
                   <scheme-name>default-backing-map</scheme-name>
                   <class-name>com.tangosol.util.SafeHashMap</class-name>
              </class-scheme>
    Is there any explanations for this?
    Thanks,
    Frederic

    Hardware config and node distribution across it? Hard to figure out what's going on if we don't know even that...
    If it's on one machine, are you swamping the CPU, memory, disk (any of) on this machine. What are the OS tools telling you. Ditto, have you probed the Coherence nodes, JVMs - and your own code - with JMX (or some other tool)?
    If you are on multiple machines, have you run the network tests that Coherence provide? What were the results?
    What backup count are you using?
    Etc. Etc. :)

  • Which trigger fires when i press cancel query button in oracle d2k forms.

    hi all,
    i have simply press then enter query but didn't enter anything in form and then press the cancel query. so i just want to know that what trigger will fire when i press the cancel query button in d2k form.
    Regards,
    kam.

    Why not ask into Forms<br>
    <br>
    Nicolas.

  • Do any events fire when the Flash Player exits?

    Hey all.
    I use a LocalConnection object to prevent being able to run our SWF multiple times on the same computer.
    The problem is that this connection can remain in place even when the SWF which called it closes. 
    I have:
    1) An External Interface call to dispose() all HTML pages call dispose() on pageunload which closes the connection.... But this is unreliable because if the browser crashes, you are locked out of the SWF
    2) I tried some crazy try/catch.  If SWF A exists and SWF B tries to be initialised.... SWFB cannot connect so it sends a function to SWFA to dispose(). This should free the connection for SWFB to connect to?  But this does not work well either because sometimes a localconnection can be in use but calling "dipose()" throws an error, often because the LocalConnection swf which should be available is already gone.
    What this all comes down to, is that I need a way to detect when the player closes, so i can close the localconnection.
    stage.addEventListener(Event.EXIT, onExit);
    function onExit(e:Event): void
             if (localconnection)
                    localconnection.close();
    Does anything like this exist?
    Thanks,

    Thanks for taking the time to answer kglad!
    I should have been clearer it is a Web App, so your answer remains valid.
    I have not completely followed you on your advice.. When you say "So it only prevents another swf from running if something is returned from a currently running swf".
    Could you expand on that? I am desperate to fix the issue, but it just seems localconnection is not the best method for "single swf execution". I just have not found any other methods.
    Thanks.

  • Does Apple discount existing MacBooks when the new ones come out?

    I haven't bought a Mac in over 10 years and I don't how Apple does business. I want a new MacBook Pro, but I'm not in a super-rush. I can wait another three months, if necessary.
    The current MacBook Pro (top of the line) is more than sufficient for me, it's just a little expensive. I certainly don't need whatever's coming next, but the current 17" is mighty attractive.
    When Apple releases the new MacBook Pro's ... (1st quarter 2010, right?) ... do the existing high-end 2009 models usually sell at a big discount to get rid of the current inventory? You know ... (like car guys say) ... blowing out last years models to make room for the 2010's?
    Is that the cheapest time to buy the previous model? When Apple releases the newest ones?

    There is no "blow-out sale" when the new models come out, at least through Apple. Apple generally keeps a very tight inventory (only a few days worth evidently) on hand, so when new models are about to be released, they are pretty low on inventory of the existing model. In fact, when new models are up for sale through Apple, the older ones disappear from their website/stores.
    Some 3rd party resellers may have discounts on older models, but they too are usually not of the "huge sale" type. A 10% discount is usually pretty generous.
    Other options are to buy a refurbished machine through Apple's website (cheapest option), or if you're a student, faculty, or staff member of an academic institution, take advantage of the student discount (also around 10%)

  • What trigger fires when a new record is requested?

    I'm trying to clear out a detail block when the user hits the button to enter a new record and cannot figure out what trigger to use or how to clear this block.
    This is a very old application and I don't even know what forms version it is in...
    Thanks, Scott

    If you don't even know the version, how can you modify the form at all?
    Check the code in the on-clear-details trigger if the form is a normal master-detail form. Clearing the detail block should be done automatically. From the manual:
    "Form Builder creates the On-Clear-Details trigger automatically when a Master/Detail block relation is defined. "
    If the form was created with its own logic to synchronize master and detail, you first have to figure out how that was done. Look for key-down, key-up, key-nxtrec etc.

  • Trigger fire when return from called form

    Witch triggers fire when returning from a called form in my master form?

    There is no trigger that fires in such events for calling form.
    It depends on your requirement.You can use WHEN-BUTTON-PRESSED trigger.
    DECLARE
    search_list paramlist;
    where_string varchar2(100);
    BEGIN
         search_list:=get_parameter_list('search_paramlist');
         IF NOT id_null(search_list) then
                   destroy_parameter_list(search_list);
         END IF;
         search_list:=create_parameter_list('search_paramlist');
         add_parameter(search_list,'P_SEARCH_SQL',text_parameter,'');
         call_form('E:\subhas\Oracle Tools\Oracle Form\Subhas_form\SEARCH.fmx',no_hide,no_replace,query_only,search_list);
    END;
    Subhas

Maybe you are looking for