Create a trigger on a view

I try to create a database trigger on a view and when the sql return a error (ORA-00439: feature not enabled: Instead-of triggers)
How can i create the trigger?
Pd. I don4t have problems to create then trigger on a table.

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

Similar Messages

  • 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

  • ORA-06552 and ORA-06553 when creating a trigger

    Hey Everyone,
    I have a issue when i try and create a trigger on a view. I get this error message.
    ORA-06552: PL/SQL: Compilation unit analysis terminated
    ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformedThis is the Desc of the view.
    Table          Column               Data Type     Length     Nullable
    NCRCPV01     ROWID               UROWID          4000     -
              LOB_ID               VARCHAR2     1     -
              PRG_ID               VARCHAR2     1     -
              PSG_ID               VARCHAR2     1     -
              SMP_ID               VARCHAR2     4     -
              PTP_ID               VARCHAR2     1     -
              COU_ISO_ID          VARCHAR2     2     -
              PLC_DOM_INT_CD          VARCHAR2     1     -
              PLC_EFFECT_DT          DATE          7     -
              PLC_EFFECT_TO_DT     DATE          7     -
              PLC_UPDT_TD          DATE          7     -
              PLC_UPDT_USER_ID     VARCHAR2     8     -
              PLC_SOFTLOCK_TS          TIMESTAMP(6)     11     -
              PLC_LATST_COL_TM     DATE          7     nullable
              PLC_HANDRATE_IN          VARCHAR2     1     nullable
              PLC_VL_MAND_ODE_IN     VARCHAR2     1     nullableThis is the SQL of the trigger im trying to exicute.
    CREATE OR REPLACE TRIGGER "UPD_NCRCPV01_TR"
       INSTEAD OF UPDATE
       ON NCRCPV01
       REFERENCING NEW AS NEW OLD AS OLD
       FOR EACH ROW
    BEGIN
       UPDATE NCADMIN.NCRCPV01@CSAHEPA_DBAAPEX.gb.tntpost.com
          SET LOB_ID = :NEW.LOB_ID,
              PRG_ID = :NEW.PRG_ID,
              PSG_ID = :NEW.PSG_ID,
              SMP_ID = :NEW.SMP_ID,
              PTP_ID = :NEW.PTP_ID,
              COU_ISO_ID = :NEW.COU_ISO_ID,
              PLC_DOM_INT_CD = :NEW.PLC_DOM_INT_CD,
              PLC_EFFECT_DT = :NEW.PLC_EFFECT_DT,
              PLC_EFFECT_TO_DT = :NEW.PLC_EFFECT_TO_DT,
              PLC_UPDT_TD = :NEW.PLC_UPDT_TD,
              PLC_UPDT_USER_ID = :NEW.PLC_UPDT_USER_ID,
              PLC_SOFTLOCK_TS = :NEW.PLC_SOFTLOCK_TS,
              PLC_LATST_COL_TM = :NEW.PLC_LATST_COL_TM,
              PLC_HANDRATE_IN = :NEW.PLC_HANDRATE_IN,
              PLC_VL_MAND_ODE_IN = :NEW.PLC_VL_MAND_ODE_IN
        WHERE ROWID = :NEW.UROWID;
    END;I find this really strange as i have created this view and trigger in my dev environment with no issues. Now when im trying to exicute the same code in my production environment im coming up against this error. The only thing that has changed is the database link in the trigger from CSPCCPA_DBAAPEX.TNTEWW.COM to CSAHEPA_DBAAPEX.gb.tntpost.com
    I have googled the error codes and it seems that the most common error is naming a column somthing like DATE, which i have not done.
    Any help here would be appreitated :)
    Thanks,
    -N.S.N.O.

    Hello,
    And are the tables (and columns) of both tables (CSPCCPA_DBAAPEX.TNTEWW.COM and CSAHEPA_DBAAPEX.gb.tntpost.com) exactly the same?
    BTW Why don't you use (the same) synonyms for those tables. Then you don't need to change your code when you move it from dev to prod...
    Greetings,
    Roel
    http://roelhartman.blogspot.com/
    You can reward this reply by marking it as either Helpful or Correct ;-)

  • 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)?

  • PLEASE HELP!! Trigger on a view that updates a table synonym?

    I have a view (PERSONINFO_VIEW) that pulls user information from several ODS.CT tables. This view contains userid, first name, last name, telephone, and email. I'm trying to create a trigger that will insert these values into a remote table with a public synonym (PERSON_CTL_SYN) using a procedure. If I run the procedure alone, it works, and the table is updated. I enter data into the view (by adding a new user account to the portal) the PERSONINFO_VIEW is updated with the new information, but the trigger that calls the procedure doesn't seem to fire, because the PERSON_CTL_SYN is not updated.
    My trigger (PERSON_SYN_INS):
    On PTS.PERSONINFO_VIEW, INSTEAD OF EACH ROW, INSERT, ENABLED
    begin
    person_syn_ins_proc(:new.userid, :new.firstname, :new.lastname,:new.phone,:new.email);
    end;
    My Procedure (PERSON_SYN_INS_PROC):
    CUSER IN VARCHAR2,
    CFIRST IN VARCHAR2,
    CLAST IN VARCHAR2,
    CPHONE IN VARCHAR2,
    CEMAIL IN VARCHAR2
    as
    cSecrGrp varchar2(30) := 'ITSUSER';
    cLoc varchar2(30) := 'OUS-ITS';
    cArea varchar2(3) := '541';
    begin
    insert into person_ctl_syn(
    person_first_name,
    person_last_name,
    person_username,
    person_email,
    person_phone_number)
    values(
    cFirst,
    cLast,
    cUser,
    cEmail,
    cPhone);
    commit ;
    end;

    I have a view (PERSONINFO_VIEW) that pulls user information from several ODS.CT tables. This view contains userid, first name, last name, telephone, and email. I'm trying to create a trigger that will insert these values into a remote table with a public synonym (PERSON_CTL_SYN) using a procedure. If I run the procedure alone, it works, and the table is updated. I enter data into the view (by adding a new user account to the portal) the PERSONINFO_VIEW is updated with the new information, but the trigger that calls the procedure doesn't seem to fire, because the PERSON_CTL_SYN is not updated.
    My trigger (PERSON_SYN_INS):
    On PTS.PERSONINFO_VIEW, INSTEAD OF EACH ROW, INSERT, ENABLED
    begin
    person_syn_ins_proc(:new.userid, :new.firstname, :new.lastname,:new.phone,:new.email);
    end;
    My Procedure (PERSON_SYN_INS_PROC):
    CUSER IN VARCHAR2,
    CFIRST IN VARCHAR2,
    CLAST IN VARCHAR2,
    CPHONE IN VARCHAR2,
    CEMAIL IN VARCHAR2
    as
    cSecrGrp varchar2(30) := 'ITSUSER';
    cLoc varchar2(30) := 'OUS-ITS';
    cArea varchar2(3) := '541';
    begin
    insert into person_ctl_syn(
    person_first_name,
    person_last_name,
    person_username,
    person_email,
    person_phone_number)
    values(
    cFirst,
    cLast,
    cUser,
    cEmail,
    cPhone);
    commit ;
    end;

  • Creating a trigger

    Hi all,
    I need help. I'm stuck.
    I'm trying to create a trigger in a TABLE_1 table.
    I've created a view that calls a function and outputs document number(number value) and the addition of business days (number value).
    VIEW CASE_A
    DOC BUSINESSD
    21562 5
    54542 8
    54523 1
    54986 9
    Since i can't call a view into a trigger, i've created the following procedure.
    create PROCEDURE CASE_1
    as
    p_out number;
    begin
    SELECT b.BUSINESSD
    INTO p_out
    FROM TABLE_1 a, CASE_A b
    WHERE a.DOC = b.DOC;
    update TABLE_1
         set field_1 = p_out;
         commit;
    END;
    this procedure is supposed to see if the doc number from table and doc number from view are equal, if so, then update it into the column field_1 in the TABLE_1 table. If i were to specifically put in a DOC number, it works. I want it to update for each doc number.
    I also need to create a trigger so that when the user inputs a date in the application and clicks on save, the value should appear in a field (field_1 from TABLE_1) in the application.
    Thank you.

    This is my CASE_A view
    DOC BUSINESSD
    21562 ---> 5
    54542 ---> 8
    54523 ---> 1
    54986 ---> 9
    This is my TABLE_1
    DOC FIELD_1
    21562
    54542
    54523
    54986
    so, this is what i'm trying to achieve in the procedure. i want to update each doc number with the businessd.
    if (DOC.CASE_A = DOC.TABLE_1)
    FIELD_1.TABLE_1 = BUSINESSD.CASE_A
    that's why i have done the update.
    Thank you.
    Edited by: user12182332 on Nov 9, 2009 11:09 AM

  • 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?

  • 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?

  • 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.

  • Before update trigger on a view

    Hello,
    is not possible to write a before update or insert trigger based on a view?
    create or replace trigger trg_bef_upd_vwangajatiabsente
    before update on vw_angajati_absente
    referencing old as old new as new
    for each row
    begin
    if :old.motivabila='N' and :new.motivabila='D' then raise_application_error(-20433, 'Nu se poate modifica o absenta nemotivabila!');
    end;is it possible to solve these situations? :)
    Regards,

    Roger22 wrote:
    regarding to 2)
    in my trigger i must raise_application_error? if i don't raise then i need to issue update statements..... ?If you have an INSTEAD OF trigger that just has a body similar to the body you posted above, that would mean that update statements either
    - Raise an error
    - Do nothing (i.e. do not update any data in any table)
    That is a syntactically valid state-- Oracle will certainly allow you to have an INSTEAD OF UPDATE trigger that effectively throws away update statements. It's just that it would be rather rare that this would be the desired behavior. Presumably, if you're going through the effort of writing the trigger, you want certain update statements to succeed and, thus, to update data. If that is the case, your trigger would have to have UPDATE statements that update the proper row(s) in the proper base table(s).
    An INSTEAD OF UPDATE trigger is literally that. You are replacing, in its entirety, the update statement against the view with the code in your trigger. So your trigger would need to issue the base table updates that Oracle would have had there not been a trigger on the view.
    Justin

  • Create a trigger to copy data from table A to table B

    Hi,
    I been trying with no success to create a trigger on table a , so when the user update or delete or insert data on that table, I would like to copy all data from table a to table b BEFORE, the statement execute, I am using Oracle database 10g XE. It's URGENT and I would appreciate any quick response.
    Thank you in advance.

    > All what I needed to do is to copy / beckup the tableA before any changes done to the table
    Why? You are not giving us a problem to look at, analyse, and assist with - you are giving us a solution. That solution says "backup table before changes are made".
    This solution sounds very strange in the context of a RDBMS. Even stranger when dealing with relational design as one would use date and time to keep track of how data is changing.
    This, and your implementation of the solution (using triggers and DDL inside it!), makes me question whether this solution is indeed at all a solution. I see flaws and problems all the way.
    What happens if two users inserts at the same time into table A? Two truncates will be fired on table B. Then the entire contents of A (and not the changes) inserted into table B? Ridiculous...
    Thus from my point of view, looking at what you have presented to the forum in this thread, you do not seem to have any grasp on how to correctly use a RDBMS, never mind use Oracle.
    Ignorance is not a problem. It is fairly easily curable. Which is why I referred you to the manuals.
    Alternatively, instead of asking the forum how to make a flawed solution works, how about instead telling us the actual problem you are trying to solve?

  • GeoRasterException: -13463 .. even after creating DML trigger

    Hi all
    i am getting the following exception :
    oracle.spatial.georaster.GeoRasterException: -13463;GeoRaster object with rasterId = 281, rdt = null not found in system data view.
    Please create DML trigger for its table and column. Do:
    sdo_geor_utl.createDMLTrigger('tableName','columnName')
    at oracle.spatial.georaster.JGeoRaster.getRasterSubset_NoComp(JGeoRaster.java:1001)
    at oracle.spatial.georaster.JGeoRaster.getRasterSubset(JGeoRaster.java:798)
    at oracle.spatial.georaster.JGeoRaster.getRasterImage(JGeoRaster.java:2510)
    at oracle.spatial.georaster.JGeoRaster.getRasterImage(JGeoRaster.java:2038)
    at spdb.SpatialQuery.getRaster(SpatialQuery.java:68)
    at spdb.SpatialQuery.main(SpatialQuery.java:91)
    I have created the DML trigger using
    sdo_geor_utl.createDMLTrigger('IMGTABLE','RASTER');
    but still i keep getting the same error
    what am i doing wrong
    THanks

    AB,
    about your application, please consider these:
    If your original images are seamlessly mosaickable, it's better to mosaick them into one large image and then query. Note, the requirement from the oracle 10g sdo_geor.mosaic is very strict.
    But I guess, in most apps, this is not practical. So, you have to query multiple images and do some work in your app. The approach could be:
    1. Since your images are all georeferenced, call sdo_geor.generateSpatialExtent and populate the spatial extent for all images. Then build a spatial index (RTree) on the georaster table based on the spatial extents. Note, If the georaster objects have different model spaces, you need call sdo_cs.transform to convert the extents to the same SRID. You can also directly update the spatial extents using a right/appropriate geometry.
    2. Spatially query the GeoRaster table using your area-of-interest geometry in a single sql stmt to filter out all the georaster objects which overlap or partially overlap your AOI.
    3. call getRasterSubset on each georaster object of the above result set with a proper window.
    4. the BLOBs returned by getrastersubset don't have any metadata inside them, but you can easily and precisely figure out their dimension sizes, cell depth, interleaving etc based on the metadata of the georaster objects as well as your query criteria (i.e., band numbers, window sizes and pyramid levels).
    5. get all blobs into your app. then you can either directly work on them, such as mosaick them into one image for display, OR you can generate RenderedImages (very easy to do thru JAI) and directly display them into one image (ie, simply render the images in a window) or call JAI rotate/tranform/mosaic to create a single image.
    The above approach has been done in many of our partner products, such as PCI FOCUS and Geomatica, Leica ERDAS Imagine and LPS.
    In addition, Oracle Applicattion Server MapViewer has this capability as well, which you might consider to use.
    Hope this helps.
    Best Regards,
    Jeffrey

  • How to create transaction for a maintenance view, Thank you.

    How to create transaction for a maintenance view,
    Thank you.
    deniz...

    Hi Deniz,
    Go to se93.
    Then create the new T.code.
    Under that select parameter Transaction.
    Then give the sm30 in the t.code in default values tab.
    check the checkbox skip initial screen.
    in classification tab.
    click checkbox inherit gui attributes..
    Now below..
    In the default values..
    select
    viewname and give ur table name.
    UPDATE= Xsave
    view - table name ( Should be upper case
    update X ( should be upper case).
    http://www.sap-basis-abap.com/sapbs011.htm
    Hope this helps you.
    Regards,
    Viveks

  • Help needed in creating a narative or title view

    Experts,
    I need some input in creating a narative or title view as header information for a report
    I am creating employee level reports in obiee 10g.
    Table Data (My table view is something like this)
    Emp ID     Emp Name                 Biz Area
    100121     Matson, Glenda     Local Corporate
    100121     Matson, Glenda     SME
    Header required to be displayed as a narative or Title view (all Fields are from my client dimension)
    Employee Information                         
    Employee ID               :     100121     
    Name                    :     Matson, Glenda     
    Role                    :     Local Corporate and SME (Both the roles played by the employee)     
    I tried even pivot, but it did not work
    Edited by: sarvan on Sep 24, 2012 11:53 AM
    Edited by: sarvan on Sep 24, 2012 11:55 AM
    Edited by: sarvan on Sep 24, 2012 11:55 AM

    Thanks for your response. I tried the same way earlier, but since same employee is playing more than one role, my narrative output is like the below.
    1282999
    Nathan, Astle
    Tech Lead
    1282999
    Nathan, Astle
    SME
    But I want the Role to appear in the same line. Something like this
    1282999
    Nathan, Astle
    Tech Lead and SME

Maybe you are looking for

  • How do i use 2 phones on one itunes account

    Hi guys hope you can help me i had a itunes account for my 3gs but my pc crashed and i had to have it sent away to be fixed and when i got it back i forgot to put itunes back on. today i got a shinny new 4gs  and set up a new account on the phone and

  • When Replacing the Logic Board....

    I recently sent my iBook in for a mulittude of repairs, including a problem with the CD R-W/DVD drive not working right. To fix this they replaced the Logic Board, but when doing so the Hard Drive was wiped. I've had my logic board replaced 100s of t

  • Serious FMP12 folder import error

    After performing a series of successful operation with Applescript and Text Wrangler I finally end up with a folder with several files UTF8 encoded on my Mac (Snow Leo 10.6.8) Trying to import this folder as text files  (Text files only, no gremlins

  • Timestamp difference

    hi all how to find the timestampdiff function can any one give me the syntax Thanks Sreedhar

  • McAfee is not working with OS x 10.10.1 - do I need it

    OS X Yosemite Version 10.10.1 I have an iMac (27 inch, Mid 2011) Processor 2.7 GHz Intel Core i5 Memory 4GB 1333 MHz DDR3 Start up Disk Macintosh HD Graphics AMD Radeon HD 6770M 512MB This is my 1st posting for help, so please excuse me if I am not f