Trigger on a view on a linked db

I have an access db that i have 'hooked' into with a database link inside of Oracle. I then have an oracle view based on that linked database so i can see the records that are over in access. This all works well. What i would like to do now is create a trigger that fires each time a new record is added over in access.
I cannot create that trigger on the database link because it is DDL and that is prohibited.
I cannot create an After Insert trigger on my oracle view because that is prohibited on views.
I can create an Instead Of trigger on the view but it never fires because the insert takes place in access not in oracle.
Is there any way for Oracle to 'detect' when a new record has been added in the Access database?

Feel like I'm getting really close to figuring this out. I created an mv on the db link like so:
DROP MATERIALIZED VIEW mv_Test_SYSDATE
CREATE MATERIALIZED VIEW mv_Test_SYSDATE
TABLESPACE users
REFRESH COMPLETE
START WITH SYSDATE
NEXT SYSDATE + 0.002 AS
SELECT acctnum, name, odometer, lastdate, cardnumber
from card@myaccessdb
If i go into the access db and insert a new record I can see the record count in the mv change after a few minutes (i'm guessing 2.8 minutes).
Which makes me happy. The problem now is that when i set up my trigger like so:
CREATE OR REPLACE TRIGGER "AZ"."TEST_MV_TRIGGER"
AFTER INSERT ON AZ.MV_TEST_SYSDATE
FOR EACH ROW
BEGIN
INSERT INTO TEST ("ACCTNUM","NAME","ODOMETER","LASTDATE","CARDNUMBER")
VALUES (:new.acctnum,:new.name,:new.odometer,:new.lastdate,:new.cardnumber);
END;
It actually does fire off of the mv which is a positive. But when i look in table test i see that it has pumped every record over, instead of just the newly added one from the access db.
I can understand why because i suppose the mv refresh is for the entire table. but I'm not at where I want to be because I want to capture the delta on the access table.
Any ideas?

Similar Messages

  • Trigger on a view

    Hi,
    using Oracle 9i + wli 8.1 sp2 + RDBMS adapter.
    can i set the trigger on a view and not on a table ?
    This way I can define a subset of the table to be checked if it changed and not
    the whole table.
    (i tried it with no success)
    Yuval

    Feel like I'm getting really close to figuring this out. I created an mv on the db link like so:
    DROP MATERIALIZED VIEW mv_Test_SYSDATE
    CREATE MATERIALIZED VIEW mv_Test_SYSDATE
    TABLESPACE users
    REFRESH COMPLETE
    START WITH SYSDATE
    NEXT SYSDATE + 0.002 AS
    SELECT acctnum, name, odometer, lastdate, cardnumber
    from card@myaccessdb
    If i go into the access db and insert a new record I can see the record count in the mv change after a few minutes (i'm guessing 2.8 minutes).
    Which makes me happy. The problem now is that when i set up my trigger like so:
    CREATE OR REPLACE TRIGGER "AZ"."TEST_MV_TRIGGER"
    AFTER INSERT ON AZ.MV_TEST_SYSDATE
    FOR EACH ROW
    BEGIN
    INSERT INTO TEST ("ACCTNUM","NAME","ODOMETER","LASTDATE","CARDNUMBER")
    VALUES (:new.acctnum,:new.name,:new.odometer,:new.lastdate,:new.cardnumber);
    END;
    It actually does fire off of the mv which is a positive. But when i look in table test i see that it has pumped every record over, instead of just the newly added one from the access db.
    I can understand why because i suppose the mv refresh is for the entire table. but I'm not at where I want to be because I want to capture the delta on the access table.
    Any ideas?

  • How to add trigger on materialized view?

    Hi, I'm trying to add trigger on materialized view. I don't know how to do it. I'm new to oracle and PL/SQL. Can you guys put some working example please? Thank you for every advise.

    Please check the below link. This answers you query:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:672989600346945045

  • Trigger of a view

    Good morning,
    Does a trigger of a view start like a trigger of a table ?
    I mean, a view searches its data in a table of a linked DB. If a row is added in the table, will the trigger of the view run ?
    Thank you very much.
    Patrick

    If a row is added in the table, will the trigger of the view run ?Triggers on views are INSTEAD OF and are specified for views as objects - NOT the tables you include in your selection in views. Because of this only DML applied to views (not tables) fire "instead of" triggers:
    SQL> create table t (id number);
    Table created.
    SQL> create view t_v as select * from t;
    View created.
    SQL> create trigger tab_t
      2  before insert on t
      3  begin
      4   dbms_output.put_line('Table trigger');
      5  end;
      6  /
    Trigger created.
    SQL> create trigger view_tr
      2  instead of insert on t_v
      3  begin
      4   dbms_output.put_line('View trigger');
      5  end;
      6  /
    Trigger created.
    SQL> insert into t values(1);
    Table trigger
    1 row created.
    SQL> insert into t_v values(2);
    View trigger
    1 row created.Rgds.

  • One more reason to put my iMAC at the curb. I can open and view Picasa photo links when I sign in via Google, but if I'm in Mail and click on the Picasa image link (my own or one someone esle sends me I can't view the images. Thye are all blank white squa

    One more reason to put my iMAC at the curb. I can open and view Picasa photo links when I sign in via Google, but if I'm in Mail and click on the Picasa image link (my own or one someone else sends me) I can't view the images. They are all blank white squares. This started a few weeks ago. Why can't I view Picasa link images through Mail?

    What you are experiencing is 100% related to Malware.
    Sometimes a problem with Firefox may be a result of malware installed on your computer, that you may not be aware of.
    You can try these free programs to scan for malware, which work with your existing antivirus software:
    * [http://www.microsoft.com/security/scanner/default.aspx Microsoft Safety Scanner]
    * [http://www.malwarebytes.org/products/malwarebytes_free/ MalwareBytes' Anti-Malware]
    * [http://support.kaspersky.com/faq/?qid=208283363 TDSSKiller - AntiRootkit Utility]
    * [http://www.surfright.nl/en/hitmanpro/ Hitman Pro]
    * [http://www.eset.com/us/online-scanner/ ESET Online Scanner]
    [http://windows.microsoft.com/MSE Microsoft Security Essentials] is a good permanent antivirus for Windows 7/Vista/XP if you don't already have one.
    Further information can be found in the [[Troubleshoot Firefox issues caused by malware]] article.
    Did this fix your problems? Please report back to us!

  • Is there a way I can view/manage devices linked to my iCloud account?

    Is there a way I can view/manage devices linked to my iCloud account? I know how to view the devices linked to my iTunes account, but I am not sure if this is possible to see with an iCloud account.

    You can't, except by seeing if they are using services associated with the account.  You could, for example, launch Find My iPhone on iCloud.com to see what devices appear (which obviously wouldn't show devices not using Find My iPhone).  Similarly, you could go to Settings>iCloud>Storage & Backup>Manage Storage to see what devices appear on the Backups list (which won't show devices not using iCloud backup).

  • Using a view as left link

    Hi All
             I want to develop a left link which will appear in every view of the application and will have the links by clicking which right view can be changed like our e-mail sites where we click on folder name and right part gets changed.
             For this functionality I have created a view for left link and added it to a view set so that i don't need to add all those links to each and every view again and again but i have a problem like when i click on the link how to change the lift link from one view to another.
    e.g.
    i have links called inbox and  spam in left link and currently showing inbox in right view now when i click on spam automatically right view should be get changed to spam folder.
    how can i achieve this functionality. Is it possible through view set or if any other way to implement this?
    Thanks in advance
    Prasanna

    Hi Prasanna,
    Create a Viewset having two regions left and right.
    In left view have all the link and attach some actions to them.
    Like
    navigateToInbox()
    navigateToSpan()
    In the actions simply fire an outbound plug to corresponding view that is embeded in right side of viewset.
    On firing of view corresponding view will be displayed in the right region.
    Regards,
    Ashwani

  • Issue with instead of trigger on a view

    Gurus,
    I have an issue with an instead of trigger on a view. The trigger is listed below. The insert and update seem to be working fine but the delete section is not.
    From the application, we have a screen on which we attach images. We trigger of an insert and update when we attach images. We are using hibernate as our object relational mapping tool.
    We have added some logging into the delete section but that portion of the trigger does not seem to be executing at all.
    Please advise.
    Thanks
    Hari
    CREATE OR REPLACE TRIGGER trg_vw_result_image_uid
    INSTEAD OF
    INSERT OR DELETE OR UPDATE
    ON vw_result_image
    REFERENCING NEW AS NEW OLD AS OLD
    DECLARE
    v_cnt number(38);
    v_cnt_old number(38);
    v_err_msg VARCHAR2 (250);
    BEGIN
    -- v_rslt_id number(38);
    -- v_cnt number(38);
    select count(1) into v_cnt from result_image_master
    where RSLT_IMAGE_ID = :new.RSLT_IMAGE_ID;
    --select count(1) into v_cnt from result_image_master
    -- where ACC_BLKBR_ID = :new.ACC_BLKBR_ID
    -- and upper(RSLT_IMAGE_NM) = upper(:new.RSLT_IMAGE_NM);
    select count(1) into v_cnt_old from result_image_master
    where RSLT_IMAGE_ID = :old.RSLT_IMAGE_ID;
    insert into t2( TEXT_VAL, DT1, seq1)
    values (' before v_cnt', sysdate, t6.NEXTVAL);
    --if v_cnt = 0
    --****INSERTING
    IF INSERTING
    THEN
    insert into t2( TEXT_VAL, DT1, seq1)
    values (' v_cnt is 0 and inserting into result_image_master', sysdate, t6.NEXTVAL);
    insert into t2( TEXT_VAL, DT1, seq1)
    values (' inserted bb id :'||:new.ACC_BLKBR_ID, sysdate, t6.NEXTVAL);
    insert into result_image_master (
    RSLT_IMAGE_ID
    ,RSLT_IMAGE_HBR_VER
    ,RSLT_IMAGE_TYPE_ID
    ,RSLT_IMAGE_NM
    ,RSLT_IMAGE_LABEL
    ,RSLT_IMAGE_SEQ
    ,RSLT_SHOW_ON_RPT
    ,RSLT_SLIDE_NO
    ,RSLT_CELL_NO
    ,RSLT_X_COORD
    ,RSLT_Y_COORD
    ,ACC_BLKBR_ID
    ,CREATED_BY
    ,DATE_CREATED
    ,MODIFIED_BY
    ,DATE_MODIFIED
    values (
    :new.RSLT_IMAGE_ID
    ,:new.RSLT_IMAGE_HBR_VER
    ,:new.RSLT_IMAGE_TYPE_ID
    ,:new.RSLT_IMAGE_NM
    ,:new.RSLT_IMAGE_LABEL
    ,:new.RSLT_IMAGE_SEQ
    ,:new.RSLT_SHOW_ON_RPT
    ,:new.RSLT_SLIDE_NO
    ,:new.RSLT_CELL_NO
    ,:new.RSLT_X_COORD
    ,:new.RSLT_Y_COORD
    ,:new.ACC_BLKBR_ID
    ,:new.CREATED_BY
    ,:new.DATE_CREATED
    ,:new.MODIFIED_BY
    ,:new.DATE_MODIFIED
    insert into result_image_blob (
    RSLT_IMAGE_ID
    ,rslt_image_blob
    values (
    :new.RSLT_IMAGE_ID
    ,:new.rslt_image_blob
    --****UPDATING
    ELSIF UPDATING
    -- v_cnt > 0 --
    THEN
    insert into t2( TEXT_VAL, DT1, seq1)
    values (' updating result_image_master', sysdate, t6.nextval);
    insert into t2( TEXT_VAL, DT1, seq1)
    values (' updating bb id :'||:new.ACC_BLKBR_ID, sysdate, t6.nextval);
    update result_image_master
    set RSLT_IMAGE_HBR_VER = RSLT_IMAGE_HBR_VER + 1
    ,RSLT_IMAGE_TYPE_ID = :new.RSLT_IMAGE_TYPE_ID
    ,RSLT_IMAGE_NM = :new.RSLT_IMAGE_NM
    ,RSLT_IMAGE_LABEL = :new.RSLT_IMAGE_LABEL
    ,RSLT_IMAGE_SEQ = :new.RSLT_IMAGE_SEQ
    ,RSLT_SHOW_ON_RPT = :new.RSLT_SHOW_ON_RPT
    ,RSLT_SLIDE_NO = :new.RSLT_SLIDE_NO
    ,RSLT_CELL_NO = :new.RSLT_CELL_NO
    ,RSLT_X_COORD = :new.RSLT_X_COORD
    ,RSLT_Y_COORD = :new.RSLT_Y_COORD
    ,ACC_BLKBR_ID = :new.ACC_BLKBR_ID
    ,MODIFIED_BY = :new.MODIFIED_BY
    ,DATE_MODIFIED = :new.DATE_MODIFIED
    where RSLT_IMAGE_ID = :new.RSLT_IMAGE_ID;
    update result_image_blob
    set rslt_image_blob = :new.rslt_image_blob
    where RSLT_IMAGE_ID = :new.RSLT_IMAGE_ID;
    END IF;
    IF DELETING OR v_cnt_old > 0
    THEN
    insert into t2( TEXT_VAL, DT1, seq1) values (' deleting rows ...', sysdate, t6.NEXTVAL);
    DELETE from result_image_blob where RSLT_IMAGE_ID = :old.RSLT_IMAGE_ID;
    insert into t2( TEXT_VAL, DT1, seq1) values ('deleting result_image_blob : '||:old.RSLT_IMAGE_ID , sysdate, t6.NEXTVAL);
    DELETE from result_image_master where RSLT_IMAGE_ID = :old.RSLT_IMAGE_ID;
    insert into t2( TEXT_VAL, DT1, seq1) values ('deleting result_image_master : '||:old.RSLT_IMAGE_ID , sysdate, t6.NEXTVAL);
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    v_err_msg := SQLERRM;
    insert into t2( TEXT_VAL, DT1, seq1) values (v_err_msg, sysdate, t6.nextval);
    END;
    Edited by: bhanujh on Sep 13, 2010 7:55 AM

    bhanujh wrote:
    The error msg that we are getting is
    09/08/2010 4:02:09 PM: Unable to save the results :: Could not execute JDBC batch updateSorry, we don't recognize this message as any valid Oracle error.
    :p

  • "instead of" trigger on a view with a condition

    I'm trying to create an instead-of trigger on a view but I want it all such that:
    1. It fires only for a certain condition.
    2. When the condition isn't met, I want the normal DML on the view to continue as it normally would.
    3. I want to avoid writing as much manual DML code as possible for long-term maintainability.
    My first attempt is like this:
    create or replace trigger PROPOSAL_PARTS_V_IRU
      instead of update on proposal_parts_v
      for each row
      WHEN :old.PART_MASTER_ID <> :new.PART_MASTER_ID
    BEGIN
      do_stuff_for_part_master_change;
    END;So when the OLD and NEW PART_MASTER_IDs have changed, I want special processing. Else, I want it to do whatever it normally does (let the view get updated and the database will manage the update of the underlying table).
    When compiling that I get "ORA-25004: WHEN clause is not allowed in INSTEAD OF triggers".
    OK I will accept that even though I want it to work.
    So my next attempt could be:
    create or replace trigger PROPOSAL_PARTS_V_IRU
      instead of update on proposal_parts_v
      for each row
    BEGIN
      IF :old.PART_MASTER_ID <> :new.PART_MASTER_ID THEN
        do_stuff_for_part_master_change;
      ELSE
        UPDATE proposal_parts -- Manually update the underlying table with manually-written DML but I hate having to do this in case the view or table columns change.
        SET...
        WHERE...
      END;So my question is...is there any syntax to do something like this?
    create or replace trigger PROPOSAL_PARTS_V_IRU
      instead of update on proposal_parts_v
      for each row
    BEGIN
      IF :old.PART_MASTER_ID <> :new.PART_MASTER_ID THEN
        do_stuff_for_part_master_change;
      ELSE
        update_row;
      END;...where "update_row" is some sort of built-in command that tells oracle to continue with the current update as if the trigger never existed.
    Back in the day I seem to remember that Oracle Forms had a trigger and syntax like this where you could intercept a DML and if under certain conditions it wasn't true, you could say "update_row" (or maybe it was "update_record?...whatever) and it meant "continue with update as if this instead-of trigger never existed".
    Is anything available like that for the DB now? I know in older versions no, but we are now on 11g...anything new come out like this?
    Otherwise I have to manually write an update statement and I'd rather not if I don't need to.
    Thanks!

    riedelme wrote:
    gti_matt wrote:
    I'm trying to create an instead-of trigger on a view but I want it all such that:
    1. It fires only for a certain condition.You can use IF Logic inside a trigger to do or not do anything. As long as it is a condition you can check you can code IF logic around it
    2. When the condition isn't met, I want the normal DML on the view to continue as it normally would.You will have to code all of your logic in the INSTEAD of trigger. The whole purpose of the INSTEAD OF trigger is to execute INSTEAD OF performing DML on the view. There is no way to go back to the "normal DML" when the INSTEAD OF trigger exists.
    You can put all of the logic you will need in the INSTEAD OF trigger and use IF conditions. Use IF logic to code both your special and "normal" processing.
    3. I want to avoid writing as much manual DML code as possible for long-term maintainability.You will have to code the operative lines somewhere. Reusable functions and/or procedures in a package?Yep using an "IF" I knew about...no problem there.
    But was just looking for a cheap and easy way to say (for the "else" condition) to revert to normal DML processing. Sounds like in a DB trigger there is no such syntax I guess.
    This is an example from Oracle Forms, I was looking for a database equivalent of this(see http://sqltech.cl/doc/dev2000/help/fbhelp18.htm):
    Built-in Subprograms for On-Event Triggers For most of the transactional On-event triggers, there is a corresponding built-in subprogram.
    On-Event Trigger
    Corresponding Built-in
    On-Delete
    DELETE_RECORD
    On-Insert
    INSERT_RECORD
    On-Update
    UPDATE_RECORD
    When you call one of these built-in subprograms from its corresponding transactional trigger, Form Builder performs the default processing that it would have done normally at that point in the transaction.
    For example, if you call the INSERT_RECORD procedure from an On-Insert trigger, Form Builder performs the default processing for inserting a record in the database during a commit operation.
    When these built-ins are issued from within their corresponding transactional triggers, they are known as do-the-right-thing built-ins. That is, they do what Form Builder would normally have done at that point if no trigger had been present. Thus, an On-Insert trigger that calls the INSERT_RECORD procedure is functionally equivalent to not having an On-Insert trigger at all. Such a trigger is explicitly telling Form Builder to do what it would have done by default anyway.Note that the author calls them the "do-the-right-thing" built-ins. That's what I was looking for but on the DB side. Sounds like Oracle didn't come up with that (yet)?

  • When I click on a link in an RSS feed it used to indicate that I'd viewed that particular link by changing the icon to the left of the link. It doesn't do that anymore. [SOLVED]

    When I click on a link in an RSS feed it used to indicate that I'd viewed that particular link by changing the icon to the left of the link. It doesn't do that anymore. This started happening right around the time I updated to Firefox 4, but may have been a little before that too. For some things, like news and web comics it's just a little annoying. For important things like looking for new journal articles for my job, it literally makes my job more difficult. So fixing this would make my day.

    I seem to have solved my own problem. When I disabled the add-on "Tab Renamizer" everything started working fine.

  • Trigger problem on Sql Server with linked server to Oracle

    Hi All,
    I have a simple insert trigger on Sql Server 2005, it uses linked server to Oracle.
    like that ;
    USE [YTM08]
    GO
    SET QUOTED_IDENTIFIER ON
    GO
    ANSI_NULLS ON
    go
    ANSI_WARNINGS ON
    CEATE TRIGGER [dbo].[YTM_TBLSTSABIT_I]
    ON [dbo].[TBLSTSABIT] FOR INSERT
    AS
    BEGIN
    INSERT INTO YTM_ORACLE..SECTOR.STOCKS
    stock_name,
    stock_code,
    insert_date
    SELECT
    SBT.STOCKNAME,
    SBT.STOCKCODE,
    GETDATE()
    FROM INSERTED SBT
    END
    The YTM_ORACLE is a linked server and it's provider is OraOLEDB.Oracle.
    Trigger does not works for that linked server but other triggers for local
    sql server works fine...
    I get this error from sql server
    'Heterogeneous queries require the ANSI_NULLS and
    ANSI_WARNINGS options to be set for the connection. This ensures consistent query semantics. Enable these options and then reissue your query.'
    Does someone know how to solve this issue the right way?
    Thanks in advance.
    Thanks !
    Adam

    Hi Lars,
      Thanks for the data. I've already read this note and configure all this parameters. But when I'm executing the Create Source System in the BI system the process dies.
      If I look into the logs I see this:
    M  call semaphore clean-up function ...
    M  ***LOG Q0E=> DpSigGenHandler, Exception (c06d007e) [dpnttool.c   432]
      That's the reason why I start guessing about other possible problem.
    Regards

  • View using db link

    I have 3 databases with identical table structure installed in 3 different servers.(East ,West & South) To view consumers bill information
    from any database I am using view with db link.
    v_bill_CASH_data is base view created in every datbase
    In east database my script for view creation is
    create or replace view v_atp_bill_data as
    select *
    from v_bill_CASH_data
    union
    select *
    from v_bill_CASH_data@westg
    union
    select *
    from v_bill_CASH_data@southg;
    where westg and southg are db links to connect to database of west and south.
    The problem is when any one of the machine is not up I am not able to view consumer's data in other two database.
    Should I change the script of view v_atp_bill_data or other way around?

    You should go in various directions
    a) make sure all databases are up 7 x 24, do not run this code during scheduled maintenance of any of the databases.
    b) Included proper error trapping
    c) consider consolidating three databases into one, adding an extra column, partioning on that column
    d) consider using Advanced Replication, Streams or Change Data Capture, or whatever applies to your version to make sure all data is available everywhere,
    when c) isn't possible.
    All other 'solutions' are doomed to failure,
    Sybrand Bakker
    Senior Oracle DBA

  • My safari won't let me view a pdf link, nor can I save it as a document. How can I view these pdfs and links?

    My safari won't let me view a pdf link, nor can I save it as a document. How can I view these pdfs and links?

    Have you installed Adobe Reader and its associated plugin? AFAIK, that's the preferred if not the only way to open PDFs in an embedded view within Safari.
    http://get.adobe.com/reader/

  • Subscibe and View slide show links now appear on upgraded site

    Subscibe and View slide show links now appear on my upgraded site ( from the previous version of iweb. Does anyone know how to get rid of them?

    Go to the "photo" inspector "photo" page and uncheck the "Allow visitors to subscribe" box.
    Click the "slideshow" button and uncheck the "enable slideshow" box.

  • How to create a trigger on a view

    Hello all,
    I am trying to create a trigger on a view that is used to update a few columns in the base table. Since I am new to trigger, an example will be appreciated.
    Thanks in advance.

    Are you sure that you need a trigger for this? Lots of folks that are new to triggers tend to overuse them before they understand the maintenance problems that having a bunch of triggers creates.
    That said, the Oracle documentation has an example of [creating an INSTEAD OF trigger on a view|http://download.oracle.com/docs/cd/B14117_01/server.101/b10759/statements_7004.htm#i2064426]
    Justin

Maybe you are looking for

  • How do I convert a .mov created in iMovie to an .mpeg?

    I am trying to post a slide show/movie I created on a website's Media Gallery. They need the file to be .mpg or .mpeg. or .wmv. (The web master said the coding isn't as important than the file type when I asked if mpeg 2, or mpeg 4 was ok. I don't un

  • Finding a variable name using BCEL

    Let's say I have a simple class with the main method. The first line in the main method looks like this: boolean x = false; How would I find the NAME of that boolean ("x") using BCEL? Thank you very much in advance. I tried searching the internet, bu

  • Is it possible to sort the catalog codes?

    Hi We use catalogs on notification for object, part, damage etc. The code is numeric. But for the user it can be difficult to find the correct code to use, as the list is not sorted. Is there a way to sort the list of catalog codes on the description

  • Xdcam ex question - progressive vs interlance ?

    hi i will be shooting a video soon with the ex3 and i'm still not sure whether to shoot P or I. if i shoot interlace and change the field dominance from upper to none, will i be getting the same progressive look that i would get while shooting progre

  • Error in the table parameter.

    Hi All, I have some Error in a table parameter in the tree model when i created the Dialog program. "Errors : ITEM_TABLE contains two items with the same name" Please help me to solve this error Regards, Luke