Instead of Insert or Update

Hello
I need help to create a trigger? I have created a form that is based on a view with two tables.
Table A - primary key SEQ_NO
Table B - foreign key FK_SEQ_NO
What Miss me in my code to make sure that table B will get correct data based on FK pointing when the data is created in the APEX according to Table A PK?
< code >
CREATE OR REPLACE TRIGGER BUI_VW_TEST
INSTEAD OF INSERT OR UPDATE
ON VW_TEST
FOR EACH LINE
BEGIN
UPDATE TABLEA
FIELDA = SET: NEW. FIELDA,
FIELDB =: NEW. FIELDB,
FIELDC =: NEW. FIELDC

UPDATE TABLEB
SET FIELDD =: NEW. FIELDD,
CRC =: NEW. CRC,
FIELDF =: NEW. FIELDF
WHERE FK_SEQ_NO =: OLD. SEQ_NO;
END BUI_VW_TEST;
< code >
I don't know that this code does not guarantee that the related data of table will A get associated Table B. Any help is appreciated, thanks.

try using the syntax below: -.

CREATE OR REPLACE TRIGGER "BUI_VW_TEST".
INSTEAD OF INSERT OR UPDATE ON 'VW_TEST '.
FOR EACH LINE
BEGIN

UPDATE TABLEA
FIELDA = SET: NEW. FIELDA,
FIELDB =: NEW. FIELDB,
FIELDC =: NEW. FIELDC;

UPDATE TABLEB
SET FIELDD =: NEW. FIELDD,
CRC =: NEW. CRC,
FIELDF =: NEW. FIELDF
WHERE FK_SEQ_NO =: OLD. SEQ_NO;

END;
/

Kumar

Tags: Database

Similar Questions

  • Errors during insertion and update form using the VIEW.

    Here is my opinion:

    CREATE OR REPLACE FORCE 
    VIEW  "SH_ADD_EMPLOYEES_VW" ("EMP_ID", "DEPT_ID", "JOB_DESC_ID", "EMPNO", "EMP_FIRST", "EMP_LAST", "USER_NAME", "USER_INI", "DEPTNO", "DEPT_DESC", "ROLES_ID", "ADMIN", "CREATES", "APPROVES", "QUALITY", "CUST_SVC", "SH_LOCAL", 
    "SH_OFFICE", "SYSTEM") 
    AS
      select
    "SH_EMPLOYEES"."EMP_ID" as "EMP_ID",
    "SH_EMPLOYEES"."DEPT_ID" as "DEPT_ID",
    "SH_EMPLOYEES"."JOB_DESC_ID" as "JOB_DESC_ID",
    "SH_EMPLOYEES"."EMPNO"  as "EMPNO",
    "SH_EMPLOYEES"."EMP_FIRST" as "EMP_FIRST",
    "SH_EMPLOYEES"."EMP_LAST" as "EMP_LAST",
    "SH_EMPLOYEES"."USER_NAME" as "USER_NAME",
    "SH_EMPLOYEES"."USER_INI" as "USER_INI",
    "SH_EMPLOYEES"."DEPTNO" as "DEPTNO",
    "SH_EMPLOYEES"."DEPT_DESC" as "DEPT_DESC",
    "DOC_ROLES"."ROLES_ID" as "ROLES_ID",
    "DOC_ROLES"."ADMIN" as "ADMIN",
    "DOC_ROLES"."CREATES" as "CREATES",
    "DOC_ROLES"."APPROVES" as "APPROVES",
    "DOC_ROLES"."QUALITY" as "QUALITY",
    "DOC_ROLES"."CUST_SVC" as "CUST_SVC",
    "DOC_ROLES"."SH_LOCAL" as "SH_LOCAL",
    "DOC_ROLES"."SH_OFFICE" as "SH_OFFICE",
    "DOC_ROLES"."SYSTEM" as "SYSTEM"
    FROM "SH_EMPLOYEES" "SH_EMPLOYEES", "DOC_ROLES" "DOC_ROLES"
    where "SH_EMPLOYEES"."EMP_ID" = "DOC_ROLES"."EMP_ID"
    /
    
    

    Here's my trigger (note - I do not use the EXCEPTION clause or (declaration of it) because it throws an error msg = >: 'This is my message'.) Here, any help would be great as well.)

    CREATE OR REPLACE TRIGGER bi_ADD_EMPLOYEES_VW
    INSTEAD OF insert ON SH_ADD_EMPLOYEES_vw
    for each row
    declare
    duplicate_info EXCEPTION;
    PRAGMA EXCEPTION_INIT(duplicate_info, -00001);
    begin
    insert into SH_EMPLOYEES
    (EMP_ID, DEPT_ID, JOB_DESC_ID, EMPNO, EMP_FIRST, EMP_LAST, USER_NAME, USER_INI, DEPTNO, DEPT_DESC)
    values
    (:new.EMP_ID, :new.DEPT_ID, :new.JOB_DESC_ID, :new.EMPNO, :new.EMP_FIRST, :new.EMP_LAST, :new.USER_NAME, :new.USER_INI, :new.DEPTNO, :new.DEPT_DESC);
    insert into DOC_ROLES 
    (ROLES_ID, ADMIN, CREATES, APPROVES, QUALITY, CUST_SVC, SH_LOCAL, SH_OFFICE, SYSTEM)
    VALUES (
    :new.ROLES_ID, :new.ADMIN, :new.CREATES, :new.APPROVES, :new.QUALITY, :new.CUST_SVC, :new.SH_LOCAL, :new.SH_OFFICE, :new.SYSTEM);
    EXCEPTION
     WHEN duplicate_info THEN
      RAISE_APPLICATION_ERROR (
       num=> -20107
       msg=> 'Duplicate employee');
    END bi_ADD_EMPLOYEES_VW;
    /
    
    

    ERROR ON UPDATE:

    ORA-20505: DML error: p_rowid = 1001,.
    p_alt_rowid = EMP_ID, p_rowid2 = 2, p_alt_rowid2 = ROLES_ID. ORA-01779: cannot change
    a column that is mapped to a table not preserved key

    ERROR WHEN INSERTING:

    ORA-01400: cannot insert NULL in
    ("SPICE_HUNTER1". "" "" SH_EMPLOYEES '. "" EMP_ID") ORA-06512: at
    "SPICE_HUNTER1. BI_SH_ADD_EMPLOYEES_VW', line 3 ORA-04088: error during execution
    relaxing ' SPICE_HUNTER1. BI_SH_ADD_EMPLOYEES_VW' ORA-06512: at
    'SYS. WWV_DBMS_SQL', line 549 ORA-06512: at "APEX_040000.WWV_FLOW_DML", line 1121
    ORA-22816: feature not supported with RETURNING clause

    Error Impossible to process line on table SH_ADD_EMPLOYEES_VW

    I see you manage emp_id is null, you must assign a value if null sequence... This column cannot be null, where the error, and "Edit" a column of this table the DML to this id value.

  • Oracle Data Integrator insert County Update comte Delete Count and error neck

    I'm trying to change an incremental update IKM Oracle

    What I have to do is insert a table at the end of each interface with the following information:

    Technologies: ORACLE

    < % if (odiRef.getOption ("METADATA_TABLE") () .length == 0) {% >}
    Invalid value for the metadata option
    < %}; % >
    / * METADATA_TABLE = < %=odiRef.getOption ("METADATA_TABLE") % > * /.
    < % / * for NO value * / if ("NONE".equals (odiRef.getOption ("METADATA_TABLE"))) {% >}
    / * Command ignored due to choice METADATA_TABLE * /.
    < %} else {% >}

    INSERT INTO < %=odiRef.getOption ("METADATA_TABLE") % >
    (
    ODI_SESSION_NO,
    ODI_SESSION_NAME,
    ODI_STEP_NAME,
    ODI_STEP_NO,
    ODI_STEP_TYPE,
    S_TABLE,
    T_TABLE,
    RUN_DATE,
    S_ROW_COUNT,
    T_ROW_COUNT
    )
    VALUES
    (
    '< % = odiRef.getSession ("SESS_NO") % >',
    '< % = odiRef.getSession ("SESS_NAME") % >',
    '< % = odiRef.getStep ("STEP_NAME") % >',
    '< % = odiRef.getStep ("NSN") % >',
    case when "< % = odiRef.getStep ("STEP_TYPE") % > ' = 'F', THEN 'Interface.
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'VD' THEN "declaring variables".
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'VS' THEN ' Set / / increment the variable'
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = have ' THEN 'variable Evaluate. "
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'V' THEN 'variable refresh.
    When ' < % = odiRef.getStep ("STEP_TYPE") % > ' = ' t ' THEN 'procedure '.
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'OE' AND 'OS command.
    When ' < % = odiRef.getStep("STEP_TYPE") % > "="IS"THEN"ODI Tool"
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'RM' and THEN 'model of bone '.
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'CM' THEN 'Check model '.
    When '< % = odiRef.getStep("STEP_TYPE") % > ' =' CS' THEN 'check sous-modèle.
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'CD' THEN 'check datastore.
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'JM' THEN 'Journalize model '.
    When '< % = odiRef.getStep ("STEP_TYPE") % >' = 'JD' THEN 'log the data store.
    END OTHER 'UNKNOWN ',.
    ' < % = odiRef.getSrcTablesList ("", "[SCHEMA].) [RES_NAME] », «, », « ») % >',
    "< %=odiRef.getTable ("L","A","TARG_NAME") % >."
    To_date (SUBSTR ("< % = odiRef.getSession ("SESS_BEG") % > ' 1, 19"), "YYYY-MM-DD HH24:MI:SS"),
    (SELECT COUNT (*)
    from < % = odiRef.getSrcTablesList ("", "[SCHEMA].) [RES_NAME] », «, », « ») % >
    where (1 = 1)
    < % = odiRef.getJoin () % >
    < % = odiRef.getFilter () % >
    < % = odiRef.getGrpBy () % >
    < % = odiRef.getHaving () % >),
    (SELECT COUNT (*) IN < %=odiRef.getTable ("L", "A", "TARG_NAME") % >)

    )
    < %}; % >

    The code above works well, however I need to update the Insert the number of rows, number of rows to update, remove the number of lines and number of rows in error via an ODI procedure.

    I managed to update (number of rows, number of update rows, number of lines, number of lines of error - remove) the table via the procedure described below:

    UPDATE ODI_PROCESS_LOAD
    SET
    INSERT_COUNT = '< % = odiRef.getPrevStepLog ("INSERT_COUNT") % >',
    UPDATE_COUNT = '< % = odiRef.getPrevStepLog ("UPDATE_COUNT") % >',
    DELETE_COUNT = '< % = odiRef.getPrevStepLog ("DELETE_COUNT") % >',
    ERROR_COUNT = '< % = odiRef.getPrevStepLog ("ERROR_COUNT") % >'
    WHERE
    ODI_SESSION_NO = '< % = odiRef.getPrevStepLog ("SESS_NO") % >'
    AND ODI_STEP_NO = '< % = odiRef.getPrevStepLog ("NSN") % >'

    What I need to do, it is by a single Insert statement mentioned above instead of the second update statement.

    I wonder if there is a way to do

    Take a look at the getPrevStepLog() method - it might be of some use, but you probably wouldn't be able to use it since the km you attempt to change:

    http://gerardnico.com/doc/ODI/Webhelp/en/ref_api/getprevsteplog.htm

  • Combining insert and update to a form?

    Hello

    I am a developer web amateur who is new to dynamic Web sites, php and dreamweaver. I am currently working on a project that uses many forms to send data to a database.

    Data that are inserted must also be available to update if necessary. so I need currently 2 versions of each form 1 to insert and the other for the update.

    Is it possible to use a single form for insert and update, instead of using 2 forms 1 for each function. This would help reduce the level of duplication on the site.

    If so is anyway to do this in Dreamweaver? or could someone point me to an example of how this can be achieved.

    Thank you all

    Thanks for the information, disappointing that Dreamweaver cannot handle it, but at least I know where I am...

    Looks like that's what I need... http://forums.Adobe.com/message/1927405

    Once again thanks for your help

  • How to modify and update a line later was inserted and updated in the doDML() method?

    Mr President

    Jdev worm is 12.2.1

    How to modify and update a line later was inserted and updated in the doDML() method?

    I added two rows in my table a method of action-listener in bean managed and secondly with operation doDML() as below.

    Method 1-first row in managed bean

        public void addNewPurchaseVoucher(ActionEvent actionEvent) {
            // Add event code here...
            BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator");        
            RowSetIterator rsi = dciter.getRowSetIterator();        
            Row lastRow = rsi.last();        
            int lastRowIndex = rsi.getRangeIndexOf(lastRow);        
            Row newRow = rsi.createRow();        
            newRow.setNewRowState(Row.STATUS_NEW);        
            rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow);         
            rsi.setCurrentRow(newRow);
            
            BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry();        
            DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator");        
            RowSetIterator rsi1 = dciter1.getRowSetIterator();        
            Row lastRow1 = rsi1.last();        
            int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1);        
            Row newRow1 = rsi1.createRow();        
            newRow1.setNewRowState(Row.STATUS_NEW);        
            rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1);         
            rsi1.setCurrentRow(newRow1); 
            
            
        }
    


    Method of doDML() of line 2 seconds in the entityImpl class


        protected void doDML(int operation, TransactionEvent e) {        
            setAmount(getPurqty().multiply(getUnitpurprice()));
           
            if (operation == DML_INSERT)  
                       {          
                         insertSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));  
                           }
                           
                           if(operation == DML_UPDATE)
                           {
                               
                           updateSecondRowInDatabase(getVid(),getLineitem(),getDebitst(),
        (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100));                        
                           }                                       
            super.doDML(operation, e);
        }
    
        private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "Insert into vdet (VID,LINEITEM,DEBITST,AMOUNT) values 
       ('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "')";  
                      System.out.println("sql= " + sql);    
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }  
                  
                  private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)  
                  {  
                    PreparedStatement stat = null;  
                    try  
                    {  
                      String sql = "update vdet set vid='"+ value1+"',lineitem='"+ value2+"',DEBITST='" 
       + value3 + "', AMOUNT='" + value4 + "' where VID='" + VID + "'";  
                      System.out.println("sql= " + sql);      
                      stat = getDBTransaction().createPreparedStatement(sql, 1);  
                      stat.executeUpdate();  
                    }  
                    catch (Exception e)  
                    {  
                      e.printStackTrace();  
                    }  
                    finally  
                    {  
                      try  
                      {  
                        stat.close();  
                      }  
                      catch (Exception e)  
                      {  
                        e.printStackTrace();  
                      }  
                    }  
                  }
    

    Now the problem is that when later I change the quantity and price of the first line isn't updated but second row, because I used the command

     <af:button actionListener="#{bindings.Commit.execute}" text="Commit"
    

    This button update the first line added by bean managed, but the second row remains unchanged.

    Please help how to update the two lines with the same button or something else.

    Concerning

    DML_UPDATE will call only if there is some change data attributes.

    I guess that the update statement is false because vid looks like a primary key for the table, then, how update you the primary key of the update statement and how the update condition statement where the vid = '0'

    I assume the update statement should look like:

      private void updateSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4)
      {
        PreparedStatement stat = null;
        try
        {
          String sql =
            "update vdet set lineitem='" + value2 + "',DEBITST='" + value3 + "', AMOUNT='" + value4 +
            "' where VID='" + value1 + "'";
          System.out.println("sql= " + sql);
          stat = getDBTransaction().createPreparedStatement(sql, 1);
          stat.executeUpdate();
        }
        catch (Exception e)
        {
          e.printStackTrace();
        }
        finally
        {
          try
          {
            stat.close();
          }
          catch (Exception e)
          {
            e.printStackTrace();
          }
        }
      }
    
  • Anyway to get a procedure to be executed after the INSERT or update?

    11g

    Hello

    I get an ORA-04091 error when I try to get a trigger to fire a procedure for me.

    Is it possible to get a procedure to run after all the INSERTIONS and UPDATES are completed.

    I tried to use a trigger "AFTER INSERT or UPDATE", but it hits the error ORA-04091.

    Ben

    And there is your problem

    insert_recheck_record_prc

    This procedure (set on the #184 line) is called in the TEST_AIUDR (line #216) trigger located on the ASSESSMENT.

    But the procedure QUESTIONS this evaluation online #191 table

    INSERT

    IN HARVEST_PLANNER (CLIENT_PRIORITY)

    SELECT b.CLIENT_PRIORITY

    OF HARVEST_PLANNER b

    EVALUATION a

    That causes the exception table mutation. The ASSESSMENT table is the mutation when the trigger on the #191 line. You cannot query the table in the procedure.

  • You want to capture update dates, with trigger on a view to refresh quickly materialized. But trigger on MV consider inserting and updates are inserts only.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production

    PL/SQL Release 11.2.0.4.0 - Production

    CORE Production 11.2.0.4.0

    AMT for Linux: Version 11.2.0.4.0 - Production

    NLSRTL Version 11.2.0.4.0 - Production

    I create the structure of the table like that.

    create table test1 (a primary key, b (2) char number, date c, d varchar2 (10), date of e);

    create table test2 (number of ab, cd (2) tank, date of the ef, gh varchar2 (10), date of the ij, kl varchar2 (100));

    Create materialized view log on test1;

    create materialized view fast refresh test1_v on commit in select * from test1;

    I have create a trigger of the sample

    CREATE OR REPLACE TRIGGER test1_trig

    AFTER INSERT OR UPDATE OR DELETE

    ON test1_v

    FOR EACH LINE

    DECLARE

    lr_test2 test2% ROWTYPE;

    lv_error VARCHAR2 (4000);

    BEGIN

    lr_test2. AB: =: NEW.a;

    lr_test2. CD: =: NEW.b;

    lr_test2. GH: =: NEW.d;

    IF THE INSERTION

    THEN

    lr_test2. EF: = SYSDATE;

    lr_test2.IJ: = SYSDATE;

    lr_test2.KL: = 'INSERT ';

    INSERT INTO test2

    VALUES lr_test2;

    ELSIF UPDATE

    THEN

    lr_test2.IJ: = SYSDATE;

    lr_test2.KL: = 'UPDATE ';

    UPDATE test2 = lr_test2 ab WHERE = LINE: OLD.a;

    ELSIF REMOVAL

    THEN

    DELETE FROM test2

    AB = WHERE: old.a;

    END IF;

    EXCEPTION

    WHILE OTHERS

    THEN

    lv_error: = SQLERRM;

    INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR

    VALUES ('test1_trig',

    : OLD.a,.

    "test1_trig,"

    LV_ERROR,

    SYSDATE);

    COMMIT;

    END test1_trig;

    /

    So, if check you my code,.

    When I insert EF = SYSDATE, IJ = SYSDATE.

    Update EF is not changed, IJ = SYSDATE.

    So I like to capture their insertion and update dates.

    But if updates or insert arrives on the materialized table. The trigger themselves as an INSERT only.

    So how do you capture the updates?

    I use the statemnet with out merger with performance and also able to capture the update dates.

    CREATE OR REPLACE TRIGGER test1_trig_merge

    AFTER INSERT OR UPDATE OR DELETE

    ON test1_v

    FOR EACH LINE

    DECLARE

    lr_test2 test2% ROWTYPE;

    lv_error VARCHAR2 (4000);

    BEGIN

    IF THE REMOVAL

    THEN

    DELETE FROM test2

        AB = WHERE: old.a;

    ELSIF INSERTION

    THEN

    MERGE INTO test2 one

    B using (SELECT 1 FROM DUAL)

    WE (ab =: new.a)

    WHEN MATCHED

    THEN

    UPDATE the VALUE ab =: NEW.a.

    CD =: NEW.b,

    GH =: NEW.c

    IJ = SYSDATE,

    KL = "Update"

    AB WHERE =: old.a

    WHEN NOT MATCHED

    THEN

    INSERTING VALUES (: NEW.a,)

    : NEW.b,.

    : NEW.c.

    : NEW.d,.

    : NEW.e,.

    "INSERT");

    END IF;

    EXCEPTION

    WHILE OTHERS

    THEN

    lv_error: = SQLERRM;

    INSERT INTO XXDOMINO_FG_DATA_LOAD_ERROR

    VALUES ('test1_trig',

    : OLD.a,.

    "test1_trig,"

    LV_ERROR,

    SYSDATE);

    END test1_trig_merge;

    /

    DISPLAY ERRORS;

  • ODI 12 c: IKM for differential insert and update with a sequence in the target table

    Hello

    I have a map where I fill in a column of my target table using a database sequence. Now my mapping is supposed to load the target gradually table. So I need a revenge for update and incremental insert. Now with this differential IKM it compares all the columns to match all colmuns line to understand, it should be an insert or update. Now, the following code shows that when the ROW_WID is loaded with a sequence of database.

    If NOT EXISTS

    (select 1 from W_LOV_D T

    where T.ROW_WID = S.ROW_WID

    and ((T.CREATED_BY = S.CREATED_BY) or (T.CREATED_BY IS NULL and S.CREATED_BY IS NULL)) and

    ....

    ....

    < the rest of the comparison of columns >

    )

    So when running ODI returns following error

    Caused by: java.sql.SQLSyntaxErrorException: ORA-00904: "S". "" ROW_WID ": invalid identifier

    Please suggest if there is no other IKM I should use or if there is another way around it without changing the code IKM...

    Hi Marc,

    Thanks for your reply.

    I had solved it. The incremental update process inserts all rows from the source table to I$ table that exists in the target table. It does so by the where sql such as mentioned in my questions as

    WHERE THERE is NOT ( . COLUMNS = . COLUMNS)

    Now in the incremental update IKM Oracle to retrieve all the columns it uses the substitution with parameter as TABLE TARGET. Due to this column sequence will in the comparison and the request fails. When I used the IKM SQL incremental update it used INTEGRATION TABLE as parameter table to pick up the columns, as I'd mentioned in the target sequence is run, so it does not get the sequence column.

    Simple answer: to solve this, use incremental update of the SQL IKM.

    Thank you

    SM

  • Create triggers in the table, sequence, insert and update with "model"?

    It must be of rtfm, trial and error thing but you wanted to ask, is it possible to have models or similar automation for the following scenario:

    1.), I add the table to the logic model

    2.) Using glossary I transform a relational model that was recovered / synchronized with the data dictionary

    3.) then I have the new table to add

    -but

    I would then have auto-DDL of to be synchronized to database:

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    -Create triggers for insert and update

    -l' idea is to have db_created_dt and db_modified_dt defined in the table, so that each table has them to the fields of record etc.

    -activate the triggers

    Each of them following the same naming convention.

    Similarity with approx. generator Apex workshop utils sql create table of the copy paste "excel" that creates 'id' - column + sequence and insert the trigger.

    rgrds Paavo

    Hi Paavo,

    most of the steps can be made in one or other way

    -create sequence for the id column

    -create table

    -create indexes for the id column pk

    If you want to start in the logic model and you don't want to have the ID column in the logic model and select 'Create the surrogate key' checkbox in the dialog entity - you will get an identity column in the relational model and the version of database and settings in ' preferences > Data Modeler > model > physics > Oracle "you can set the sequence generation and the trigger for taking in load.

    fields of record defined in the table, so that each table has them

    You can add the same set of columns in all tables with the transformation script 'model of Table... ».

    You can also look here Oracle SQL Developer Data Modeler 4.1 user - defined DDL generation using transformation scripts

    to see how to grant your DDL generation using the transformation script. DM comes with example to generate separate tables of logging and triggers. You can create your build script of triggers that support logging in these common columns.

    Philippe

  • Insert an Update statement in a Trigger

    I'm new to APEX and I'm trying to determine the best place to put an update for an audit table.

    This is the trigger that I work with:

    create or replace trigger "LEASES_T1"
    BEFORE
    insert or update or delete on "LEASES"
    for each row
    begin
        if inserting then
            :new.CREATION_DATE := sysdate;
            :new.created_by := nvl(v('APP_USER'),user);
            :new.last_update_date := sysdate;
            :new.last_update_by := nvl(v('APP_USER'),user);
    
        elsif updating then
            :new.last_update_date := sysdate;
            :new.last_update_by := nvl(v('APP_USER'),user);
        end if;
    
    end;
    INSERT INTO LEASE_AUDIT (LEASE_ID) VALUES (P2_ROWID);
    
    


    It is a basic triggers relaxation I raised a stock APEX.  It works fine without the addition of the audit at the end.  It updates the data created or changed for a table called LEASES.  During the same operation, I want to record this action in the audit table, LEASE_AUDIT.  The barebones for this statement is on line 18, above.

    Passing through some other posts which dealt with similar issues, it seemed that it would be timely to update in the trigger, but I don't know where it would go.  In this case, the statement is at the end, since it does not matter whether registration in the leases table exists or not.  The PK for LEASES is configured to be a ROWID generated by the screen (I have since been notified that a sequence may be a better method).

    So, how framing this statement to work?  Or is this oddball approach?

    I'm on APEX 4.2.4 on 11g.  My experience has been Access and VBA, mainly on autonomous databases (non-SQL Server backend).

    Thank you!

    I think a composed trigger may be the way to go.  I'll throw it against the wall and see if it sticks.

    Thank you!

  • Superior on Insert and Update

    I have a form created from a VO.  In the input text, I set the contentStyle property "text-transform: uppercase;"  This converts uppercase, but it is always added to the database as lowercase.  I want the value to be uppercase when a record is inserted or updated in the database.  It is perhaps obvious to most, but I need advice.  What is the best way to do this?

    I use JDev 11.1.2.

    You can replace th he of the attribute setter in OS and convert the value to upper case. Or you can use a groovy for that expression.

    Timo

  • Limitation of Table inserts and updates.

    Hi friends,

    I learn Oracle PL/SQL.

    I need to create a table for audit purposes. I want the table to be updated only by a procedure and not by all users.

    I have also some paintings, where only a few columns must be accessible to insert or update to users. The remaining columns in this table may not be editable.

    How can I achieve this in Oracle PL/SQL. Help, please.

    Thank you

    Deepak

    I learn Oracle PL/SQL.

    I need to create a table for audit purposes. I want the table to be updated only by a procedure and not by all users.

    Place the table in diagram A. Do not give access to this table to other drawings.

    Create a procedure/package to diagram A - he can write/update the table has.

    Grant execute access to this procedure/package to other drawings.

    I have also some paintings, where only a few columns must be accessible to insert or update to users. The remaining columns in this table may not be editable.

    Something like

    grant update (col1, col2) on tableA to UserB;

    See GRANT

  • Add error causing senior in 4.2.1 when inserting and updating same time

    Hi all

    I have problems with the top to add a line in a table.

    There is already a thread here on how to add the line above in table form in version 4.0.

    We have recently upgraded to version 4.2.1 Apex.

    Since then we have question while inserting a new line and update an existing line at the same time, and then click Save button causing the error below:

    Current version of the data in the database has changed since the user initiated the update process. version of current line identifier = "xxxxxx" line application version identifier = "xxxxxx".

    But insert a new record and update an existing record works well separately with an error.


    Here's the code to add the line at the top of page header HTML

    <script language="javascript" type="text/javascript">
    function addRowTop()
    {
    apex.widget.tabular.addRow();
    apex.jQuery(apex.widget.tabular.gTabForm).find(".highlight-row").last()
    .insertBefore(apex.jQuery(apex.widget.tabular.gTabForm).
    find(".highlight-row").first());
    }
    </script>
    

    If I use by default addRow so absolutely no problem to insert and update at the same time.

    Here is the example of work in the workspace apex.

    Looks like a bug to me.

    Can any of the Oracle team please see this and let us know if it needs a patch.

    Thank you

    REDA

    Not sure that I consider this a bug since you are somehow hacking the default functionality of the APEX.  Maybe you could add a feature request 'Add Top line' to https://apex.oracle.com/vote

    It seems that you hit some enhancments to safety that have been made to the tabular forms. You should be able to work around it by putting the new lines to the bottom of the form before submitting the page.

    Create a dynamic action based on the click of the submit button.

    Event: click on

    Selection type: button

    Button: SUBMIT (Submit)

    Condition: - no requirement.

    Add real action to run the JavaScript Code:

    Action: run the JavaScript Code

    Fire when the result of the event is: true

    Fire on Page load: [disabled]

    Code:

    apex.jQuery(apex.widget.tabular.gTabForm).find("input[value=''][name='frowid']").closest(".highlight-row")
     .insertAfter(apex.jQuery(apex.widget.tabular.gTabForm).find(".highlight-row").last());
    

    Add a real action to send the page:

    Action: send the Page

    E: Nam request/buttonSUBMIT

    -Jeff

  • TRIGGER BEFORE INSERT OR UPDATE OR DELETE

    I want to create a single trigger before each insert or update or delete, a record gets copied into the AUDIT table. works very well on the insertion and to day but you have problem clear.

    Can you please help me debug this error. The problem of mutation.

    create or replace

    BIU_FS_Test_T RELAXATION

    BEFORE INSERT OR UPDATE OR DELETE

    ON FS_Test

    REFERRING AGAIN AS NINE OLD AND OLD

    FOR EACH LINE

    DECLARE

    number of voffender_history_id;

    Start

    IF the INSERTION

    SELECT FS_Test_history_seq. nextval in the double voffender_history_id;

    INSERT INTO FS_Test_history (OFFENDER_HISTORY_ID,

    OFFENDER_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME.

    SX, SKIN_TONE, HEIGHT, WEIGHT, RACE, EYE_COLOR,

    HAIR_COLOR, BLOOD_TYPE, VARIOUS, DATE_OF_BIRTH.

    PLACE_OF_BIRTH, TRANSACTION)

    VALUES (voffender_history_id,

    : new. OFFENDER_ID,: new. First name: new. MIDDLE_NAME,: new. LAST_NAME,

    : new. RACE: new. SX,: new. SKIN_TONE,: new. HEIGHT: new. WEIGHT: new. EYE_COLOR,

    : new. HAIR_COLOR,: new. BLOOD_TYPE,: new. VARIOUS: new. DATE_OF_BIRTH,

    :new. PLACE_OF_BIRTH,

    "INSERT");

    ELSIF UPDATE

    et (

    NVL (:OLD. First name, 'x') <> nvl():NEW. First name, 'x') or

    NVL (:OLD. MIDDLE_NAME, 'x') <> nvl():NEW. MIDDLE_NAME, 'x') or

    NVL (:OLD. Last_name, 'x') <> nvl():NEW. Last_name, 'x') or

    NVL (:OLD. RACE 0) <> nvl():NEW. RACE 0) or

    NVL (:OLD. SX 0) nvl(:NEW <>.) SX 0) or

    NVL (:OLD. SKIN_TONE 0) <> nvl():NEW. SKIN_TONE 0) or

    NVL (:OLD. HEIGHT 0) <> nvl():NEW. HEIGHT 0) or

    NVL (:OLD. WEIGHT 0) <> nvl():NEW. WEIGHT 0) or

    NVL (:OLD. EYE_COLOR 0) <> nvl():NEW. EYE_COLOR 0) or

    NVL (:OLD. HAIR_COLOR 0) <> nvl():NEW. HAIR_COLOR 0) or

    NVL (:OLD. BLOOD_TYPE 0) <> nvl():NEW. BLOOD_TYPE 0) or

    NVL (:OLD. VARIOUS, ' x') <> nvl():NEW. VARIOUS, ' x') or

    NVL (:OLD. DATE_OF_BIRTH, January 1, 1900 ") <> nvl():NEW. " DATE_OF_BIRTH, January 1, 1900 ") or"

    NVL (:OLD. PLACE_OF_BIRTH 0) <> nvl():NEW. PLACE_OF_BIRTH 0)

    )

    THEN

    SELECT FS_Test_history_seq. nextval in the double voffender_history_id;

    INSERT INTO FS_Test_history (OFFENDER_HISTORY_ID,

    OFFENDER_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME.

    SX, SKIN_TONE, HEIGHT, WEIGHT, RACE, EYE_COLOR,

    HAIR_COLOR, BLOOD_TYPE, VARIOUS, DATE_OF_BIRTH.

    PLACE_OF_BIRTH, TRANSACTION)

    VALUES (voffender_history_id,

    : new. OFFENDER_ID,: new. First name: new. MIDDLE_NAME,: new. LAST_NAME,

    : new. RACE: new. SX,: new. SKIN_TONE,: new. HEIGHT: new. WEIGHT: new. EYE_COLOR,

    : new. HAIR_COLOR,: new. BLOOD_TYPE,: new. VARIOUS: new. DATE_OF_BIRTH,

    :new. PLACE_OF_BIRTH, "UPDATE");

    ELSIF DELETION THEN

    SELECT FS_Test_history_seq. nextval in the double voffender_history_id;

    SELECT FS_Test_history_seq. nextval in the double voffender_history_id;

    INSERT INTO FS_Test_history (OFFENDER_HISTORY_ID,

    OFFENDER_ID, FIRST_NAME, MIDDLE_NAME, LAST_NAME.

    SX, SKIN_TONE, HEIGHT, WEIGHT, RACE, EYE_COLOR,

    HAIR_COLOR, BLOOD_TYPE, VARIOUS, DATE_OF_BIRTH.

    PLACE_OF_BIRTH, TRANSACTION)

    VALUES (voffender_history_id,

    : new. OFFENDER_ID,: new. First name: new. MIDDLE_NAME,: new. LAST_NAME,

    : new. RACE: new. SX,: new. SKIN_TONE,: new. HEIGHT: new. WEIGHT: new. EYE_COLOR,

    : new. HAIR_COLOR,: new. BLOOD_TYPE,: new. VARIOUS: new. DATE_OF_BIRTH,

    :new. PLACE_OF_BIRTH, 'CLEAR');

    END IF;

    end;

    Error I get

    Error from the 1 in the command line:

    Remove from the fs_test where PK = 41476

    Error report:

    SQL error: ORA-04091: table get OUT. SOR_O_HISTORY is changing, function of triggering/can not see

    ORA-06512: at «GET. » BIU_FS_TEST_T', line 111

    ORA-04088: error during execution of trigger ' EB. BIU_FS_TEST_T'

    04091 00000 - «table %s. » "%s is changing, function of triggering/can not see.

    * Cause: A trigger (or plsql user-defined function that is referenced in)

    ( this statement) attempted to watch (or modify) a table that has been

    in the middle to be modified by the statement that shot.

    * Action: Rewrite the trigger (or function) so it does not read this table.

    PS 11g r2

    Thank you.

    n_shah18-

    Is there a parent-child relationship between the tables involved in the triggering event? Is there a foreign key used above the child table that references the parent table?

    If you have a parent-child relationship and a trigger on the parent table must be running some DML on the child table, and, if the child table as a foreign key (FK) back to the parent table, any DML on the child table will cause a recursive SQL statement to check the constraint. Indirectly, this will cause an exception table mutation.

    So watch the dependencies on SOR_O_HISTORY / FS_TEST_HISTORY/all other related table. A FOREIGN KEY can make it to mutate (no pun intended).

    Hope this will help you find the root cause.

  • INSERT and UPDATE audit generating more lines expected in $ AUD

    Environment:

    Oracle 11.2.0.3 EE on Solaris

    I had a request for verification of the INSERT and UPDATE on the activities of all the tables in a particular schema. It was in anticipation of a request that will live and the owner wanted to see a 'typical' of some test users activity.

    Here are the steps I took:
    alter system set audit_trail=DB_EXTENDED scope=spfile;
    
    Bounce the instance
    
    audit INSERT table, UPDATE table by USERX;
    I also "audit_sys_operations = TRUE' so I know I'll take some SYS audit data in $ AUD as well, but I can ask around those."

    My question is that I see several connections from the application server with "LOGIN" and "LOGOUT" actions and I don't know why they are appearing in the table of AUD $.

    Is it because I have auditing enabled for inserts and updates on all THE tables for USERX and opening operations and logoff do I/O in tables that are not owned by USERX under logon logoff procedure?

    I'm a newbie audit and the docs I read not answered this question.

    I just found an article on the value of 'SESSION_REC' of ACTION_NAME and I need to change my check to "by access. I'll change that and see what happens, but it shouldn't change my question.

    Thanks much for any help!

    -gary

    Hello

    I have the SYS activities audited but I never said anything about the session auditing for this particular user.
    

    "audit session;" check all successful and failed connections to and disconnections of the database, regardless of the user, by session

    Is there a way to confirm what has been turned on for auditing?
    

    You can check with the following query

    Select * from dba_stmt_audit_opts;
    Select * from dba_priv_audit_opts;

    You can also check out the link below for more deatails
    http://psoug.org/reference/auditing.html

Maybe you are looking for