BULK INSERT into View w/ Instead Of Trigger - DML ERROR LOGGING Issue

Oracle 10.2.0.4
I cannot figure out why I cannot get bulk insert errors to aggregate and allow the insert to continue when bulk inserting into a view with an Instead of Trigger. Whether I use LOG ERRORS clause or I use SQL%BULK_EXCEPTIONS, the insert works until it hits the first exception and then exits.
Here's what I'm doing:
1. I'm bulk inserting into a view with an Instead of Trigger on it that performs the actual updating on the underlying table. This table is a child table with a foreign key constraint to a reference table containing the primary key. In the Instead of Trigger, it attempts to insert a record into the child table and I get the following exception: +5:37:55 ORA-02291: integrity constraint (FK_TEST_TABLE) violated - parent key not found+, which is expected, but the error should be logged in the table and the rest of the inserts should complete. Instead the bulk insert exits.
2. If I change this to bulk insert into the underlying table directly, it works, all errors get put into the error logging table and the insert completes all non-exception records.
Here's the "test" procedure I created to test my scenario:
View: V_TEST_TABLE
Underlying Table: TEST_TABLE
PROCEDURE BulkTest
IS
TYPE remDataType IS TABLE of v_TEST_TABLE%ROWTYPE INDEX BY BINARY_INTEGER;
varRemData remDataType;
begin
select /*+ DRIVING_SITE(r)*/ *
BULK COLLECT INTO varRemData
from TEST_TABLE@REMOTE_LINK
where effectiveday < to_date('06/16/2012 04','mm/dd/yyyy hh24')
and terminationday > to_date('06/14/2012 04','mm/dd/yyyy hh24');
BEGIN
FORALL idx IN varRemData.FIRST .. varRemData.LAST
INSERT INTO v_TEST_TABLE VALUES varRemData(idx) LOG ERRORS INTO dbcompare.ERR$_TEST_TABLE ('INSERT') REJECT LIMIT UNLIMITED;
EXCEPTION WHEN others THEN
DBMS_OUTPUT.put_line('ErrorCode: '||SQLCODE);
END;
COMMIT;
end;
I've reviewed Oracle's documentation on both DML logging tools and neither has any restrictions (at least that I can see) that would prevent this from working correctly.
Any help would be appreciated....
Thanks,
Steve

Thanks, obviously this is my first post, I'm desperate to figure out why this won't work....
This code I sent is only a test proc to try and troubleshoot the issue, the others with the debug statement is only to capture the insert failing and not aggregating the errors, that won't be in the real proc.....
Thanks,
Steve

Similar Messages

  • Form with view having instead-of-trigger gives FRM-40501 and ORA-02014

    I created a data-entry from with a 'view' as datas-source block. This view gives crosstab query results with a data from a single base-table but it is complex and uses decode and aggregate funciton 'max' just to create group by in a crosstab query. I have created a instead of trigger on this view to update or insert a record in base table. A test to update base table works fine at SQl prompt. A test to insert at SQL shows '1 row created' but in fact when I query the database, it does not show newly inserted row. Also, when I compile and run this form, I get FRM-40501 and ORA-02014. Help!!!
    I know that DML operations on a view with DECODE, aggregate functions or group by can not be performed but I thought the "instead of" trigger on the view to update the base table should eleminate this restriction and hence pusued further but now stuck!
    BTW: I can post details of base table, view, and instead of trigger, if you want to see them to further decipher the problem. Just let me know. Thanks!
    VERSIONS: Forms in developer suite v10.1.2.0.2 on Windows XP 64 bit desktop - ; Backend database: 9.2.0.8 on Windows 2003 EE server
    Edited by: user8647268 on Aug 19, 2009 1:19 PM
    Edited by: user8647268 on Aug 19, 2009 1:25 PM

    I just forgot to ask you one question: In my experience with forms, I have captured before_value and after_value and implemented logic based on results many times. This form I am working on is kinda first multi-record form where I have a tabular page with date and about 7 other columns forming a grid of cells, which users wanted. Each line is a record from a view. I tried relying on forms to do DML on underlying table and since the underlying table is a paritioned table, I ran into FRM-40509 and ORA-00936, where returning ROWID becomes problematic. I found a note 167550.1 which says to set Key mode to 'Updateable' or 'Non-Updateable' but not 'Unique' or 'Automatic' as a solution #1. Solution#1 failed i.e. the errors persisted. The note also says in that case, implement Solution #2, which is to write explicit trigger to do each of the DML on view. Here I run into kinda problem: In a tabular form with say 31 records each row having 7 cells which is like capturing 217 before values..that is too many. Addressing them with ':old.xxx' or ':new.xxx' which works in instead of trigger, does not work in trigger inside forms. Without checking these before and after values, it inserts rows with nulls for empty cells where we wnated it to skip and do nothing. So iam looking for a way to capture before value using some kinda standard form mechanism..Do you have any suggestions! (Sorry for long explanation but that is the only way to do it..)

  • Issue in Invoking an Updatable View with Instead of Trigger

    Hi,
    I am trying to insert a record using Updatable View with Instead of Trigger. When i try to save the data, i get the below error:
    java.sql.SQLException: ORA-01403: no data found
    ORA-06512: at line 1
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:457)
    at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:405)
    at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:889)
    at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:476)
    at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:204)
    at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:540)
    at oracle.jdbc.driver.T4CCallableStatement.doOall8(T4CCallableStatement.java:213)
    at oracle.jdbc.driver.T4CCallableStatement.executeForRows(T4CCallableStatement.java:1075)
    at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1466)
    at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3752)
    at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3887)
    at oracle.jdbc.driver.OracleCallableStatement.executeUpdate(OracleCallableStatement.java:9323)
    at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1508)
    at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:172)
    at oracle.jbo.server.OracleSQLBuilderImpl.doEntityDML(OracleSQLBuilderImpl.java:432)
    at oracle.jbo.server.EntityImpl.doDMLWithLOBs(EntityImpl.java:8566)
    Can someone help me resolve this issue?
    Also it would be great if you can share Sample codes for Invoking an updatable view with instead of trigger on Save/commit.
    Regards,
    Jeevan

    As a trigger is executed in the db and not in your app it's really hard to help as you did not give any useful information.
    Have you read this blog http://stegemanoracle.blogspot.com/2006/03/using-updatable-views-with-adf.html ?
    Timo
    Edited by: Timo Hahn on 22.09.2011 09:15
    And my friend google also found http://technology.amis.nl/blog/1447/adf-business-components-resfresh-after-insertupdate-and-instead-of-triggers

  • How to create ADF BC components like EO from  "View with INSTEAD OF trigger

    I have a "View with INSTEAD OF trigger" on a external schema. is it possible to create ADF EO on top of this view in my local schema?. If possible, then is it possible to insert/update that external table using ADF standard data controls and Application module?. I'm trying to see if it's possible with standard ADF controls without calling pl/sql API to insert/update that external table. any ideas are appreciated.
    Regards,
    Surya

    http://stegemanoracle.wordpress.com/2006/03/15/using-updatable-views-with-adf/

  • Insert into views

    Hi,
    Using instead of triggers how can i insert into views. give me example of that. its very helpful to me
    thanks in advance

    Hi,
    Refer
    http://www.databasejournal.com/features/mssql/article.php/1437741
    Might be useful.
    Cheers
    Nirmal
    [pre[                                                                                                                                                                                                                                                                                                   

  • Bulk insert into oracle using ssis

    Hi ,
    Can someone please suggest me the way to Bulk insert data into oracle database? I'm using oledb which doesnt support bulk insert into oracle.
    Pls note I cant use Oracle ATTUnity as it requires enterprise edition but i have only Standard edition and hence that option is ruled out.
    Is there any other way that I can accompolish BULK insert?
    Please help me out.
    Thanks,
    Prabhu

    Hi Prabhu,
    I am very late to help you solve the query but following is the solution to 'Bulk Insert into Oracle' that worked for me.
    To use below code for SSIS 2008 R2 in a
    Script Task component you would need following API references.
    Prerequisites:
    1. C:\Program Files (x86)\Microsoft SQL Server\100\SDK\Assemblies\Microsoft.SQLServer.DTSRuntimeWrap.dll
    2. Install "Oracle Data Provider For .NET 11.2.0.1.0" and add a reference to
    Oracle.DataAccess.dll.
       Microsoft SQL Server Integration Services Script Task
       Write scripts using Microsoft Visual C# 2008.
       The ScriptMain is the entry point class of the script.
     *  Description : SQL to Oracle Bulk Copy/Insert
     *  Created By  : Mitulkumar Brahmbhatt
     *  Created Date: 08/14/2014
     *  Modified Date   Modified By     Description
    using System;
    using System.Data;
    using Microsoft.SqlServer.Dts.Runtime;
    using System.Windows.Forms;
    using Oracle.DataAccess.Client;
    using Microsoft.SqlServer.Dts.Runtime.Wrapper;
    using System.Data.OleDb;
    namespace ST_6e18a76102dd4312868504c4ef95279d.csproj
        [System.AddIn.AddIn("ScriptMain", Version = "1.0", Publisher = "", Description = "")]
        public partial class ScriptMain : Microsoft.SqlServer.Dts.Tasks.ScriptTask.VSTARTScriptObjectModelBase
            #region VSTA generated code
            enum ScriptResults
                Success = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Success,
                Failure = Microsoft.SqlServer.Dts.Runtime.DTSExecResult.Failure
            #endregion
            public void Main()
                ConnectionManager cm;
                IDTSConnectionManagerDatabaseParameters100 cmParams;
                OleDbConnection oledbConn;
                DataSet ds = new DataSet();
                string sql;
                try
                    /********** Pull Sql Source Data into a Dataset *************/
                    cm = Dts.Connections["SRC_CONN"];
                    cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
                    oledbConn = (OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection;
                    sql = @"Select * from [sourcetblname]'';
                    OleDbCommand sqlComm = new OleDbCommand(sql, oledbConn);
                    OleDbDataAdapter da = new OleDbDataAdapter(sqlComm);
                    da.Fill(ds);
                    cm.ReleaseConnection(oledbConn);
                    /***************** Bulk Insert to Oracle *********************/
                    cm = Dts.Connections["DEST_CONN"];
                    cmParams = cm.InnerObject as IDTSConnectionManagerDatabaseParameters100;
                    string connStr = ((OleDbConnection)cmParams.GetConnectionForSchema() as OleDbConnection).ConnectionString;
                    cm.ReleaseConnection(oledbConn);
                    sql = "destinationtblname";
                    using (OracleBulkCopy bulkCopy = new OracleBulkCopy(connStr.Replace("Provider=OraOLEDB.Oracle.1", "")))
                        bulkCopy.DestinationTableName = sql;
                        bulkCopy.BatchSize = 50000;
                        bulkCopy.BulkCopyTimeout = 20000;
                        bulkCopy.WriteToServer(ds.Tables[0]);
                    /***************** Return Result - Success *********************/
                    Dts.TaskResult = (int)ScriptResults.Success;
                catch (Exception x)
                    Dts.Events.FireError(0, "BulkCopyToOracle", x.Message, String.Empty, 0);
                    Dts.TaskResult = (int)ScriptResults.Failure;
                finally
                    ds.Dispose();
    Mitulkumar Brahmbhatt | Please mark the post(s) that answered your question.

  • DML ERROR LOGGING STATEMENT FAILS FOR MULTITABLE INSERT

    When I use a simple expression in my dml error logging statement for a multitable insert I get 'end of file on communication channel' on the compile(in all guis tested). It works fine without the simple expression for the multitable insert. The simple expression works ok with a single table insert.
    example:
    this works ok for single table insert and blows up on multitable inserts:
    LOG ERRORS INTO ERR$_INVOICE (TO_CHAR(SYSDATE,'YYYYMMDD HH:MI:SS')) REJECT LIMIT UNLIMITED;
    this works ok for both:
    LOG ERRORS INTO ERR$_CINVOICE REJECT LIMIT UNLIMITED;
    any ideas?

    No version number, no DDl, and no DML. No help is possible.
    Complete version information and a demo that people can run to duplicate your situation will increase the chance of getting help.
    I, for example, have no idea what you intend with the statement multitable insert. Is this a reference to INSERT ALL or INSERT FIRST or some other syntax?

  • Storing XML using XSU, object VIEW and INSTEAD OF trigger

    Here is the point:
    I've got 2 tables which are linked:
    CREATE TABLE dept (
    deptno NUMBER PRIMARY KEY,
    deptname VARCHAR2(20)
    CREATE TABLE emp (
    empno NUMBER PRIMARY KEY,
    empname VARCHAR2(20),
    deptno NUMBER REFERENCES dept(deptno)
    I've got the following message, which I want to insert in the tables using XSU (I already have a PL/SQL stored procedure which work perfectly for insertion into 1 table, using DBMS_XMLSave.insertXML or xmlgen.insertXML):
    <DEPT>
    <DEPTNO>10</DEPTNO>
    <DEPTNAME>IT</DEPTNAME>
    <EMP>
         <EMPNO>1</EMPNO>
         <EMPNAME>John</EMPNAME>
    </EMP>
    <EMP>
         <EMPNO>1</EMPNO>
         <EMPNAME>Phil</EMPNAME>
    </EMP>
    </DEPT>
    So I've created the following object:
    CREATE TYPE emp_t AS OBJECT
    empno NUMBER,
    empname VARCHAR2(20)
    CREATE TYPE emplist_t AS TABLE OF emp_t;
    CREATE TYPE dept_t AS OBJECT
    deptno NUMBER,
    deptname VARCHAR2(20),
    emplist emplist_t
    Now I understand that I should create an object VIEW and an INSTEAD OF trigger (That's what I read many times),
    but I don't know how to structure the view and the trigger.
    Could you help? (Example of a similar context, piece of code)
    Thanks a lot
    Marion

    Hi John,
    I have exactly the same issue as you experienced back in January. I have a complex data modelling requirement which requires the need to pivot rows into columns using ROW_NUMBER() and PARTITION clauses. To hide the complexity from the middle tier, I have created a database view and appropriate INSTEAD OF triggers and mapped my EO to the view. I have overriden the lock() method on the EO implementation class (to avoid ORA-02014) and would like to try the same solution you used with the pl/sql call to lock the record.
    My question is, how did you manage the release of the lock if the transaction was not rolled back or committed by your application i.e. if the user closed the browser for instance.
    In my naivity, I would like to think that the BC4J framework would release any locks for the database session when it found the servlet session to be terminated however my concern is that the lock would persist and cause complications.
    Any assistance greatly appreciated (if you would be willing to supply your lock() method and pl/sql procedure logic I would be even more grateful!).
    Many thanks,
    Dave
    London

  • View with instead of trigger still not updatable

    Hi everybody,
    could somebody explain how to make this view updatable?
    I have the following log:
    CREATE OR REPLACE FORCE VIEW BRS_V_VERPLICHTINGEN
    (VERPLICHTING_NR
    ,ONTSTAANSJAAR
    ,OMSCHRIJVING
    ,DATUM_VERANTWOORDING
    ,OBJECT_NR
    ,OBJECT_NAAM
    ,CDG_CODE
    ,TMA_CODE
    ,CREATED_BY
    ,CREATION_DATE
    ,LAST_UPDATED_BY
    ,LAST_UPDATE_DATE)
    AS SELECT vw_brs_verplichting.verplichting_nr
    ,     vw_brs_verplichting.ontstaansjaar
    ,     nvl( brs_verplichtingen.omschrijving, vw_brs_verplichting.verplichting_oms
    ,     vw_brs_verplichting.datum_verantwoording
    ,     vw_brs_verplichting.object_nr
    ,     vw_brs_verplichting.object_naam
    , brs_verplichtingen.cdg_code
    ,     brs_verplichtingen.tma_code
    ,     brs_verplichtingen.created_by
    ,     brs_verplichtingen.creation_date
    ,     brs_verplichtingen.last_updated_by
    ,     brs_verplichtingen.last_update_date
    FROM vw_brs_verplichting
    ,     brs_verplichtingen
    WHERE vw_brs_verplichting.vervallen_code = 'N'
    AND vw_brs_verplichting.verplichting_nr = brs_verplichtingen.verplichting_nr
    AND vw_brs_verplichting.ontstaansjaar = brs_verplichtingen.ontstaansjaar
    View created
    CREATE OR REPLACE TRIGGER BRS_VVG_IRU
    INSTEAD OF UPDATE
    ON BRS_V_VERPLICHTINGEN
    BEGIN
    brs_vvg_pck.instead_of_row_update( :new.verplichting_nr
    , :new.ontstaansjaar
    , :new.omschrijving
    , :new.cdg_code
    , :new.tma_code
    END ;
    Trigger created
    SELECT COLUMN_NAME
    ,     INSERTABLE
    ,     UPDATABLE
    ,     DELETABLE
    FROM USER_UPDATABLE_COLUMNS
    WHERE TABLE_NAME = 'BRS_V_VERPLICHTINGEN'
    COLUMN_NAME INSERTABLE UPDATABLE DELETABLE
    VERPLICHTING_NR YES YES YES
    ONTSTAANSJAAR YES YES YES
    OMSCHRIJVING NO NO NO
    DATUM_VERANTWOORDING YES YES YES
    OBJECT_NR YES YES YES
    OBJECT_NAAM NO YES NO
    CDG_CODE NO YES NO
    TMA_CODE NO YES NO
    CREATED_BY NO YES NO
    CREATION_DATE NO YES NO
    LAST_UPDATED_BY NO YES NO
    LAST_UPDATE_DATE NO YES NO
    12 rows selected
    But that one column still isn't updatable... however because i'm using an INSTEAD OF UDPATE trigger they should all be updatable, shouldn't they?
    I'm using the 10g database...
    Hope someone can help...
    Regards,
    Robert

    Justin,
    you might try to grant the views to the FLOWS_xxxxx user, which performs the Apex processes.
    Dik Dral

  • Bulk Insert into a Table from CSV file

    I have a CSV file with 1000 records and i have to insert those records into a table.
    I tried for Bulk Insert command and Load data infile command but it throws error.
    Am using Oracle 10g Express Edition.
    I want to achieve it thru query command and not by plsql procedures
    Please send me query syntax for this problem. . . .
    Thanks in Advance,
    Hariharan ST.

    Hi
    If you create an external table that points to your csv file you will then be able populate your table from a query.
    See: http://www.astral-consultancy.co.uk/cgi-bin/hunbug/doco.cgi?11210
    Hope this helps

  • View and Instead of trigger

    Hi !
    In my application I have two tables
    tabA(col_A1,col_A2,col_A3) and tabB(col_B1,col_B2)I created a view
    CREATE OR REPLACE VIEW  vt
    AS SELECT  col_A1, col_A2, col_A3, col_B1, col_B2
         FROM  tabA  A
                 LEFT OUTER JOIN  tabB  B
                   ON (        A.ol_Achar = B.col_Bchar
                       OR 'A'||A.ol_Achar = B.col_Bchar ); and an instead of trigger
    CREATE OR REPLACE TRIGGER vt_upd
      INSTEAD OF UPDATE ON vt
    BEGIN
      UPDATE    tabA
         SET    col_A3 = :NEW.col_A3
         WHERE  col_A1 = :NEW.col_A1;
    END;
    /And now there are very strange behaviours on an update statement I've tried:
    UPDATE vt SET col_A3=1 where col_A1=2;1.) If I try it on an Oracle instance version 10.2.0.1.0 it's OK, the update (and hence the instead of triggers) does the right thing.
    2.) If I try it on an Oracle instance version 9.2.0.7.0 I get an error:
    ORA-01031: insufficient privileges3.) If I change the the definition to:
    CREATE OR REPLACE VIEW  vt
    AS SELECT  col_A1, col_A2, col_A3, col_B1, col_B2
         FROM  tabA  A
                 LEFT OUTER JOIN  tabB  B
                   ON A.ol_Achar = B.col_Bchar;the update will work on 9.2.0.7.0 as well.
    Any idea why there are such troubles ?
    Thanks for any help,
    Heinz

    Don't have 9.2.0.7 at hand and your view definition is a bit screwed. But what I tried was
    michaels>  create table taba(col_a1 varchar2(5),col_a2 varchar2(5),col_a3 varchar2(5))
    Table created.
    michaels>  create table tabb(col_b1 varchar2(5),col_b2 varchar2(5))
    Table created.
    michaels>  create or replace view vt
    as
       select col_a1, col_a2, col_a3, col_b1, col_b2
         from taba a left outer join tabb b
              on (a.col_a1 = b.col_b1 or 'A' || a.col_a2 = b.col_b2)
    View created.
    michaels>  create or replace trigger vt_upd
       instead of update
       on vt
    begin
       update taba
          set col_a3 = :new.col_a3
        where col_a1 = :new.col_a1;
    end vt_upd;
    Trigger created.
    michaels>  update vt
       set col_a3 = 1
    where col_a1 = 2
    0 rows updated.
    michaels>  select * from v$version
    BANNER                                                         
    Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
    PL/SQL Release 9.2.0.8.0 - Production                          
    CORE     9.2.0.8.0     Production                                      
    TNS for HPUX: Version 9.2.0.8.0 - Production                   
    NLSRTL Version 9.2.0.8.0 - Production Maybe time to upgrade?

  • View with Instead of Trigger - ORA-01031

    I am having trouble with a form based on a view that uses an instead of trigger.
    When I attempt to update a complex view that uses instead of triggers in an APEX form, I get the following message:
    ORA-20001: Error in DML: p_rowid=21388, ... ORA-01031: insufficient privileges
    The view works correctly when updates are executed from SQL Plus.
    The view "VW" is based on several tables in the application schema "X", which is parsed by APEX, and several tables in another schema "Z". I have explicitly granted select permission on the tables in schema "Z" to schema "X", but this doesn't resolve the error.
    Any idea how to fix this problem? From reading other posts, it sounds like the only issue should be explicit grants on the tables in other schemas. I do not attempt to update the tables in schema "Z", and do not have update permissions to those tables.
    Sinerely, Justin

    Justin,
    you might try to grant the views to the FLOWS_xxxxx user, which performs the Apex processes.
    Dik Dral

  • Bulk insert into a table

    What is the counter part for sql server BULK insert in Oracle.
    I have gone through an existing thread for the same question Bulk Insert CSV file in Oracle 9i But here it is suggested to read from a file into and external table and then to create my own table reading from external table.
    But I want to read directly from a file to an existing table in my database. How do I achieve this?
    Thank you,
    Praveen.

    Refer to
    http://download.oracle.com/docs/cd/B14117_01/server.101/b10825/ldr_modes.htm#i1008078
    "During Direct Path load through SQL Loader, some constaints and all db triggers are disabled. With the conventional path load method, arrays of rows are inserted with standard SQL INSERT statements—integrity constraints and insert triggers are automatically applied.
    After the rows are loaded and indexes rebuilt, any triggers that were disabled are automatically reenabled. The log file lists all triggers that were disabled for the load. There should not be any errors reenabling triggers."

  • Insert into a table using DB trigger

    Hi,
    I want to create a trigger on mytableA during INSERT or UPDATE:
    When a record is created or updated in mytableA, I would like to insert a record into mytableB.
    Before inserting, I would like to check if the corresponding mytable data already exists in the mytableB.
    I was wondering if there's any better PLSQL code rather than using something like this.
    select count(1) from mytableB where...
    if count(1) <0 then
    insert into mytableB
    end if;
    OR
    use a no data found logic
    Note: I will not be doing an UPDATE to mytableB if the record already exists.
    Thanks in Advance.
    Anto

    Hi,
    I am using 10g.
    Could you give me an example on how to form a MERGE for DB trigger.
    I tried something like this:
    MERGE INTO mytableB
    USING (SELECT col1,col2,col3 FROM mytableA) A
    ON (A.col1=:new.col1)
    WHEN NOT MATCHED THEN INSERT (col1,col2,col3e)
    VALUES (:NEW.col1,:NEW.col2,:NEW.col3);
    But since I am write a trigger on mytableA , SELECT might cause trigger mutating.
    Please suggest.
    Thanks.
    Anto

  • ADF BC: Creating updatable VO based upon DB View with "instead of" trigger

    Hello all,
    I have got an interesting issue. I have an Oracle DB view that is used to hide some complexity in the underlying DB design (it does some unions). This view is updatable because we have created an "instead of" update trigger to update the correct table when a row is updated. This is working fine in SQL.
    Next, we have created an ADF Entity object based upon the view, specifying an appropriate PK for the DB View. Then, we have created an updatable VO based upon the EO. All well and good so far. The issue we have is in trying to commit changes to the DB - because the ADF BC framework is trying to lock the row to update (using SELECT ... FOR UPDATE), it's not working because of ORA-02014 - cannot select FOR UPDATE from view with DISTINCT, GROUP BY, etc.
    This leads me to thinking about overridding doSelect() on the EO as hinted here http://radio.weblogs.com/0118231/stories/2005/07/28/differenceBetweenViewObjectSelectAndEntityDoselectMethod.html
    As a temporary test, we have over-ridden the EO's doSelect to call super.doSelect(false) and it does work, although we will have lost update issues as detailed in Steve's article.
    My questions:
    1). Is overriding doSelect() the correct thing here? Perhaps there is a better way of handling this problem? I do have a base EO class from which all of the EO's extend, so adding this behavior should be straightforward.
    2). Does anyone have example doSelect implementation? I am thinking of overriding doSelect for my EO and calling super.doSelect (lock=false), but then I need to deal with some possible exceptions, no?
    Kind regards,
    John

    Hi John,
    I have exactly the same issue as you experienced back in January. I have a complex data modelling requirement which requires the need to pivot rows into columns using ROW_NUMBER() and PARTITION clauses. To hide the complexity from the middle tier, I have created a database view and appropriate INSTEAD OF triggers and mapped my EO to the view. I have overriden the lock() method on the EO implementation class (to avoid ORA-02014) and would like to try the same solution you used with the pl/sql call to lock the record.
    My question is, how did you manage the release of the lock if the transaction was not rolled back or committed by your application i.e. if the user closed the browser for instance.
    In my naivity, I would like to think that the BC4J framework would release any locks for the database session when it found the servlet session to be terminated however my concern is that the lock would persist and cause complications.
    Any assistance greatly appreciated (if you would be willing to supply your lock() method and pl/sql procedure logic I would be even more grateful!).
    Many thanks,
    Dave
    London

Maybe you are looking for