Deferred Constraints

Hi,
One of our projects is using Kodo to link Java to the Oracle db I works fine with 8.1.7 but we need to connect to a Lite db.
Kodo is running this query which fails because Oracle Lite does not have a DEFERRED column in the ALL_CONSTRAINTS table. I can't find any info on deferred constraints in Lite.
Does Lite handle constraints in the same way?
Is there a workaround ?
Peter
SELECT t2.OWNER AS PKTABLE_SCHEM,
t2.TABLE_NAME AS PKTABLE_NAME,
t2.COLUMN_NAME AS PKCOLUMN_NAME,
t0.OWNER AS FKTABLE_SCHEM,
t0.TABLE_NAME AS FKTABLE_NAME,
t0.COLUMN_NAME AS FKCOLUMN_NAME,
t0.POSITION AS KEY_SEQ,
DECODE (t1.DELETE_RULE,
'NO ACTION', 3,
'RESTRICT', 1,
'CASCADE', 0,
'SET NULL', 2,
'SET DEFAULT', 4) AS DELETE_RULE,
t0.CONSTRAINT_NAME AS FK_NAME,
DECODE (t1.DEFERRED,
'DEFERRED', 5,
'IMMEDIATE', 6) AS DEFERRABILITY
FROM ALL_CONS_COLUMNS t0,
ALL_CONSTRAINTS t1,
ALL_CONS_COLUMNS t2
WHERE t0.OWNER = t1.OWNER
AND t0.CONSTRAINT_NAME = t1.CONSTRAINT_NAME
AND t1.CONSTRAINT_TYPE = 'R'
AND t1.R_OWNER = t2.OWNER
AND t1.R_CONSTRAINT_NAME = t2.CONSTRAINT_NAME
AND t0.POSITION = t2.POSITION;

Peter,
Please let us know if you still need help with this post.
Thank you.

Similar Messages

  • Reporting exceptions on deferred constraints

    Is it possible to report exceptions on deferred constraints? I am using this mechanism to load tables in an arbitrary order and to prevent FK violations whilst loading.
    As a starting point, the script below works as expected (enabling and disabling):
    CREATE TABLE EXCEPTIONS
    ( ROW_ID ROWID
    , OWNER VARCHAR2(30)
    , TABLE_NAME VARCHAR2(30)
    , CONSTRAINT VARCHAR2(30)
    CREATE TABLE EMP( ENAME VARCHAR2(10));
    ALTER TABLE EMP ADD CONSTRAINT EMP_UK UNIQUE (ENAME) DEFERRABLE;
    ALTER TABLE EMP DISABLE CONSTRAINT EMP_UK;
    INSERT INTO EMP VALUES ('SMITH');
    INSERT INTO EMP VALUES ('SMITH');
    ALTER TABLE EMP ENABLE CONSTRAINT EMP_UK EXCEPTIONS INTO EXCEPTIONS;
    SELECT * FROM EXCEPTIONS;
    However, I don't want to disable constraints, because the application may be performing DML in another session.
    So in the script below I'm deferring the constraints instead of disabling them. But how can I report the constraint violations in this scenario?
    CREATE TABLE EXCEPTIONS
    ( ROW_ID ROWID
    , OWNER VARCHAR2(30)
    , TABLE_NAME VARCHAR2(30)
    , CONSTRAINT VARCHAR2(30)
    CREATE TABLE EMP( ENAME VARCHAR2(10));
    ALTER TABLE EMP ADD CONSTRAINT EMP_UK UNIQUE (ENAME) DEFERRABLE;
    ALTER SESSION SET CONSTRAINTS=DEFERRED;
    INSERT INTO EMP VALUES ('SMITH');
    INSERT INTO EMP VALUES ('SMITH');
    -- Which statement goes here to report constraint violations?
    SELECT * FROM EXCEPTIONS;
    The statement:
    SET CONSTRAINTS ALL IMMEDIATE;
    will validate deferred constraints and result in a SQL Error: ORA-00001: unique constraint (SCOTT.EMP_UK) violated
    But this does not tell me the rows.
    The statement:
    ALTER TABLE EMP ENABLE CONSTRAINT EMP_UK EXCEPTIONS INTO EXCEPTIONS;
    results in the following error, and no rows in the exceptions table:
    SQL Error: ORA-02091: transaction rolled back
    ORA-00001: unique constraint (SCOTT.EMP_UK) violated
    Is there any way to report the violations?
    At the end, I'd like to report ALL violating rows to the user.
    The best I can come up with is, for each constraint perform:
    SET CONSTRAINT EMP_UK IMMEDIATE;
    and in the exception handler explicitly query for duplicates in the table:
    SELECT ENAME FROM EMP GROUP BY ENAME HAVING COUNT(*) > 1;
    I hope there is a better way.

    I believe this will not be usable in a scenario in which the tables are loaded in the "wrong" order. The database will only be consistent after all tables have been loaded. Using DML error logging will produce false errors. Please correct me if I'm wrong.

  • Influence of deferred constraint to Table is mutating proble

    Hello,
    i have a question regarding the 'Table is mutating,
    Trigger/Function may not see it'-problem. I
    wondered whether a deferrable constraint can solve the problem,
    but as I tested it, it's the same
    behaviour as before.
    Situation:
    assume tables LOC_TO and TORDER and the following constraint:
    ALTER TABLE LOC_TO ADD (CONSTRAINT LT_TOID FOREIGN KEY (LT_TOID)
    REFERENCES TORDER ON DELETE CASCADE
    DEFERRABLE INITIALLY DEFERRED);
    assume a trigger on table TORDER:
    create or replace trigger tIU_TORDER_ADD
    after insert or update of TO_STATE on TORDER
    for each row
    declare
    begin
    insert
    into loc_to
    ( lt_locid,
    lt_toid )
    values
    ( 'HRL14042',
    :new.to_id )
    end tIU_TORDER_ADD;
    I thought, that on a deferred constraint at the triggered action
    no check to TORDER is done, and
    that this fact will prevent the ORACLE_ERROR ORA-04091.
    Can anyone tell me, why this doesn't work?
    Thanks
    Titus Leskien
    null

    There was a loophole in the mutating table gotcha: single row inserts in a BEFORE EACH ROW trigger were not considered mutating, but were in AFTER EACH ROW triggers. This did not apply to INSERT INTO ... SELECT ... statements, which always mutated, even if they only inserted one row.
    This is get-out is no longer included in the documentation, but as you have found still applies in the 9.2 database (and it's unlikely Oracle will have broken it in 10g).
    Cheers, APC

  • Reporting of deferred constraint failures

    Hello
    I'm running Kodo 3.1.4 in WebLogic 8.1 against Oracle 9. I'd like to run
    with deferred constraints but there are problems reporting failures of
    these constraints: the database rolls back but no exception is thrown by
    weblogic or KoDo. The user is therefore presented with a silent failure
    (though the correct exception is written into the weblogic container log).
    Running with DataSourceMode set to enlisted (rather than local) produces
    the expected exceptions when constraints fail but the constraints are no
    longer correctly deferred (they are tested after each statement).
    I'm all out of ideas. Can anyone point me in the right direction?
    TIA
    Robert

    There should be some sort of client exception... are you sure that you
    are not consuming it? Are you using a WL datasource?
    Robert Donkin wrote:
    Hello
    I'm running Kodo 3.1.4 in WebLogic 8.1 against Oracle 9. I'd like to run
    with deferred constraints but there are problems reporting failures of
    these constraints: the database rolls back but no exception is thrown by
    weblogic or KoDo. The user is therefore presented with a silent failure
    (though the correct exception is written into the weblogic container log).
    Running with DataSourceMode set to enlisted (rather than local) produces
    the expected exceptions when constraints fail but the constraints are no
    longer correctly deferred (they are tested after each statement).
    I'm all out of ideas. Can anyone point me in the right direction?
    TIA
    Robert--
    Steve Kim
    [email protected]
    SolarMetric Inc.
    http://www.solarmetric.com

  • Deferred constraints &  XAExceptions details

    When executing an XA transaction on Oracle 8i with a J2EE server, we are not getting enough details in the OracleXAException that occurs as a result of a deferred constraint being violated (during the commit).
    We're getting a oracle.jdbc.xa.OracleXAException (wrapped inside a TransactionRolledBackException), and upon further inspection I can call the OracleXAException methods:
    getOracleError() : int
    getOracleSQLError() : int
    I cannot get any textual details about the error (ie. which constraint was violated).
    Do other version of Oracle provide more details during XA transaction failures?
    Thanks,
    M

    <BLOCKQUOTE><font size="1" face="Verdana, Arial, Helvetica">quote:</font><HR>Originally posted by SAMEER DESHPANDE ([email protected]):
    Hello
    I would like to know the use of Deferred Constraints.
    At the time of COMMMIT, the Oracle ROLLBACKS the transaction if I set "SET CONSTRAINT ALL DEFERRED;"...
    What is the use of DEFERRED CONSTRAINTS...?
    Thanks
    Sameer<HR></BLOCKQUOTE>
    You can do "SET CONSTRAINT ALL IMMEDIATE" before committing. That statement will raise an error, without rolling back the transaction, if there are violated constraints.

  • Deferred Constraints - error on inserting

    Hi there,
    i've got a very courios problem with deferred constraints. My table creates are:
    CREATE TABLE mitglied
    ( svnr NUMBER(10) NOT NULL,
      instr VARCHAR(20) NOT NULL,
      CONSTRAINT mitglied_pk PRIMARY KEY (svnr));
    CREATE TABLE abteilung
    ( instr VARCHAR(20) NOT NULL,
      geleitetVon NUMBER(10) NOT NULL,
      stvVon NUMBER(10) NOT NULL,
      CONSTRAINT abteilung_pk PRIMARY KEY (instr),
      CONSTRAINT abteilung_geleitetVon_fk FOREIGN KEY (geleitetVon)
                 REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE,
      CONSTRAINT abteilung_stvVon_fk FOREIGN KEY (stvVon)
                 REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE);
    ALTER TABLE mitglied
      ADD CONSTRAINT mitglied_fk FOREIGN KEY (instr)
                     REFERENCES abteilung(instr) INITIALLY DEFERRED DEFERRABLE;My Inserts (from sql-file):
    INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', '20-JAN-2005', 'Posaune');
    <all of the other "mitglied"-inserts>
    INSERT INTO abteilung VALUES ('Posaune', '1833040984', '1512101070');
    <all of the other "abteilung"-inserts>
    COMMIT;The Error msg:
    Error starting at line 79 in command:
    INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', '20-JAN-2005', 'Posaune')
    Error report:
    SQL Error: ORA-02091: transaction rolled back
    ORA-02291: integrity constraint (U0426435.MITGLIED_FK) violated - parent key not found
    (it's the same for all of the other mitglied-inserts), and of course, I get also errors on the abteilung-inserts.
    I've already tried to solve this problem by using "SET AUTOCOMMIT OFF" in sqlplus, but that wasn't the point.
    What's wrong with my Constraints?

    Please post a complete example cut-n-paste from SQL*Plus window that shows the exact output step by step (as like below).
    It apparently works for me as shown below.
    SQL> CREATE TABLE mitglied
      2  ( svnr NUMBER(10) NOT NULL,
      3    mName VARCHAR(30) NOT NULL,
      4    gJahr INTEGER NOT NULL,
      5    aDat DATE NOT NULL,
      6    instr VARCHAR(20) NOT NULL,
      7    CONSTRAINT mitglied_pk PRIMARY KEY (svnr));
    Table created.
    SQL> CREATE TABLE abteilung
      2  ( instr VARCHAR(20) NOT NULL,
      3    geleitetVon NUMBER(10) NOT NULL,
      4    stvVon NUMBER(10) NOT NULL,
      5    CONSTRAINT abteilung_pk PRIMARY KEY (instr),
      6    CONSTRAINT abteilung_geleitetVon_fk FOREIGN KEY (geleitetVon)
      7               REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE,
      8    CONSTRAINT abteilung_stvVon_fk FOREIGN KEY (stvVon)
      9               REFERENCES mitglied(svnr) INITIALLY DEFERRED DEFERRABLE);
    Table created.
    SQL> ALTER TABLE mitglied
      2    ADD CONSTRAINT mitglied_fk FOREIGN KEY (instr)
      3                   REFERENCES abteilung(instr) INITIALLY DEFERRED DEFERRABLE;
    Table altered.
    SQL> INSERT INTO mitglied VALUES ('1833040984', 'Edwin Neugebauer', '1984', to_date('20-JAN-2005', 'dd-mon-yyyy'), 'Posaune');
    1 row created.
    SQL> INSERT INTO abteilung VALUES ('Posaune', '1833040984', '1512101070');
    1 row created.
    SQL> commit ;
    commit
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-02291: integrity constraint (OPS$LAPTOP\KKISHORE.ABTEILUNG_STVVON_FK)
    violated - parent key not found
    SQL>Message was edited by:
    Kamal Kishore

  • EjbRemove fails with deferred constraints in 8.1.6

    I get a constraint violation under certain conditions from Oracle.
    IBM ejb container hides the exception, and raises a CSI_ROLLBACK exception. The only workaround I can think of, is disabling all constraints in Oracle, and trusting IBMs Application server to guarantee the
    referential integrity of the database.
    Does anyone else notice these problems and found a resolution?
    Oracle introduced deferred constraints to allow the constraint violation checking at the end of an transaction.
    For the IBM implementation of entity EJBs this is essential,
    because any the "DELETE FROM WHERE id=" which result from an ejbRemove() happens >>>before<<< an ejbStore() which results in "UPDATE SET foreignkey = NULL ".
    I am using the jdbc driver from classes12.zip, and noticed that
    you get an constraint violation on a commit, when the record has been created in a transaction, is updated in a transaction, and then is deleted in a transaction. The transactions are isolated.
    A rollback, and deleting again resolves the problem.
    But the problem is that an Websphere Application server is in between the
    delete from a user, and the jdbc driver accessed through a datasource.
    null

    Does anyone know where to configure and find required settings (e.g. the number of open_cursors) for Oracle 8.1.6 server when using the jdbc thin driver ?
    null

  • Feedback deferred constraint is incorrect in sql developer 2.1.0.63.41

    In the earlier 2.1.0.63 the set contraint didnt work entirely in sql developer.
    In this new release the set constraint can be executed and it works, however when you violate a constraint there is no feed back.
    example:
    I create the following table and insert 2 rows
    CREATE TABLE d_orafout
    ( code NUMBER CONSTRAINT d_codepk PRIMARY KEY DEFERRABLE,
    message VARCHAR2(50))
    INSERT INTO d_orafout VALUES(904,'invalid table name')
    INSERT INTO d_orafout VALUES(903,'invalid column name')
    Then i execute:
    set constraint d_codepk deferred;
    set succeeded.
    Then an update that violates the primary key:
    update d_orafout set code = 903 where message = 'invalid table name';
    1 rows updated
    Then when i commit i should get the following error (which works fine in SQL*Plus):
    ORA-02091: transaction rolled back
    ORA-00001: unique constraint (NWG806.D_CODEPK) violated
    However the commit gives me the following output:
    commit;
    commited
    The transaction is not commited, it is rolledback but i dont get the error i need.

    Hi <please supply your name>,
    Thanks for this feedback,
    I have replicated this issues and I have logged a bug.
    Bug 9201183 - COMMIT REPORTING COMMIT INCORRECTLY WHEN USED WITH SET CONSTRAINT DEFERRED
    Regards,
    Dermot.
    SQL Developer Team

  • Deferring Constraint Checking

    In the Oracle Lite documentation, there is a section:
    ==========================================================
    3.11.3.2 Defer Constraint Checking Until After All Transactions Are Applied
    1. Drop all foreign key constraints and then recreate them as DEFERRABLE constraints.
    2. Bind user-defined PL/SQL procedures to publications that contain tables with referential integrity constraints.
    3. The PL/SQL procedure should set constraints to DEFERRED in the BeforeApply function and IMMEDIATE in the AfterApply function as in the following example featuring a table named SAMPLE3 and a constraint named address.14_fk:
    ==========================================================
    For step 1, I am assuming this is on the base table that the publication references, since it is the one throwing the FK constraint violations at me.
    For step 2 however, are these procedures to be bound to the base tables as well, or somewhere else related to where the publication items are stored?
    Thanks,
    Allen

    In this case, the data model that I have to work with causes this situation
    TABLE A has 2 FK constraints to TABLE B
    TABLE B has 1 FK constraint to TABLE A
    In Oracle Lite, I:
    1-create a record in TABLE A where both of the columns with FK constraints are null
    2-create a record in TABLE B which refers to the original in TABLE A
    3-create a second record in TABLE B which also refers to the record in TABLE A
    4-update the record in TABLE A to refer to the 2 records in TABLE B
    When these changes reach the mobile server, they are placed in the error queue, because steps 1 and 4 are being combined and performed as one single insert. Since the records from step 2 and 3 don't exist yet, there is an FK violation.
    Is there a way to prevent the synchronization process from 'opitimizing' the transaction and combining steps 1 and 4? Everything works fine if I follow steps 1-4, but when 1 and 4 are combined it all falls apart.
    Thanks,
    Allen

  • Deferred constraints and transaction

              Hello.
              Let me explain my problem:
              1. I have table TBL_BASE in database Oracle with one column - ID (Primary Key)
              2. I have several entity bean with CMP which mapped to according tables in database,
              all of which has foreign key to TBL_BASE.ID.
              3. All FK constraints is DEFERRABLE, INITIALY DEFERRED.
              4. All methods in entity are marked as REQUIRED transaction.
              5. In ejbRemove method I try to remove the record from TBL_BASE first - I must
              be able do that because I have not committed transactio
              The problem is I receive error - that I cant do that because Foreign Key violation.
              It's look like that WebLogic try call commit on exit of method ejbRemove before
              real delete identity from database.
              

              Sorry.
              I found the issue. The problem was that I used DataSource in the ejbRemove. I
              change it ot TXDataSource and everything are working now. Thank you.
              "Yuriy Kuzmenko" <[email protected]> wrote:
              >
              >Hello.
              >Let me explain my problem:
              >1. I have table TBL_BASE in database Oracle with one column - ID (Primary
              >Key)
              >2. I have several entity bean with CMP which mapped to according tables
              >in database,
              >all of which has foreign key to TBL_BASE.ID.
              >3. All FK constraints is DEFERRABLE, INITIALY DEFERRED.
              >4. All methods in entity are marked as REQUIRED transaction.
              >5. In ejbRemove method I try to remove the record from TBL_BASE first
              >- I must
              >be able do that because I have not committed transactio
              >
              >The problem is I receive error - that I cant do that because Foreign
              >Key violation.
              >It's look like that WebLogic try call commit on exit of method ejbRemove
              >before
              >real delete identity from database.
              >
              

  • Deferred constraint at session level

    Can you define a specific constraint to be deferred at the session level?
    I know that all deferrable constraints can be set deferred at the[b] session level:
    ALTER SESSION SET CONSTRAINTS = DEFERRED;
    But what if I want a certain constraint only to be set deferred at the session level?
    thank u

    SET CONSTRAINT[S]

  • Deferring constraints

    Hi,
    What's the difference between initially immediate and NOT DEFFERABLE? so initially deferred waits to check the constraint until the transaction ends. But when?! After issuing commit/rollback?
    and initially immediate checks the constraint at the statement execution. so in my opinion INITIALLY IMMEDIATE is same as NOT DEFERRABLE.
    By default the constraint is NOT DEFERRABLE, so the validity is checked immediately after the DML statement.
    thanks
    Edited by: Roger22 on 09.09.2011 14:08

    Also, something else to be aware of, which is not necessarily a difference
    the ROLLBACK occurs on all transactions, even those that were succecsfull when DEFERRED, and a COMMIT failed on a check;
    Whereas when IMMEDIATE, the rollback would occur only on the transaction that failed.
    SQL> insert into t1 values (1,1);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> insert into t2 values (1);
    1 row created.
    SQL> insert into t2 values (2);
    insert into t2 values (2)
    ERROR at line 1:
    ORA-02291: integrity constraint (XDB_DEV3.T2_FK) violated - parent key not found
    SQL> select * from t2;
             A
             1
    SQL> rollback;
    Rollback complete.
    SQL> select * from t2;
    no rows selected
    SQL> alter session set constraints = deferred;
    Session altered.
    SQL> insert into t2 values (1);
    1 row created.
    SQL> insert into t2 values (2);
    1 row created.
    SQL> commit;
    commit
    ERROR at line 1:
    ORA-02091: transaction rolled back
    ORA-02291: integrity constraint (XDB_DEV3.T2_FK) violated - parent key not found
    SQL> select * from t2;
    no rows selected

  • Deferable Constraint of NO USE

    I heard deferrable constraint do a check at the end of
    transaction...
    I have statement like this in java
    insert into master(parent_id) values (2);
    insert into child(child_id) values (2);
    commit;
    I have the relation like this
    master.parent_id-->child.child_id
    Deferable initially Deferred
    When I try to run it it gives me
    violated - parent key not found
    If it give me this error what is the deferrable constraint used for ?

    Sorry for above post..
    I was little mislesaded in code..

  • Data Modeler 3.0 EA1: Import deferrable column constraints

    Importing from Data dictionary. Table has a deferrable initially deferred column constraints.
    create table didmn( m number check (mod(m,2)=1) deferrable initially deferred
                      , mn number constraint didmn_modmn_chk check (mod(mn,2)=1) deferrable initially deferred
                      , constraint didmn_mnn_chk check (mn/m=3) deferrable initially deferred
                      , check (mn>m) deferrable initially deferred
                    );Column level constraints are NOT DEFERRABLE in DDL Preview. Also after merge to a model they are in physical model not deferrable. As in my earlier foreign key thread Data Modeler 3.0 EA1: Import deferrable foreign key
    Table level constraints are imported deferrable.
    Edited by: Rafu on 19.10.2010 14:34

    Hi Rafu,
    EA2 is available and those DEFERRABLE problems are sorted out there.
    Philip

  • Anyone know setting primary key deferred help in the bulk loading

    Hi,
    Anyone know by setting primary key deferred help in the bulk loading in term of performance..cos i do not want to disable the index, cos when user query the existing records in the table, it will affect the search query.
    Thank You...

    In the Oracle 8.0 documentation when deferred constraints were introduced Oracle stated that defering testing the PK constraint until commit time was more efficient than testing each constraint at the time of insert.
    I have never tested this assertion.
    In order to create a deferred PK constraint the index used to support the PK must be created as non-unique.
    HTH -- Mark D Powell --

Maybe you are looking for

  • My HP Photosmart C4599 will no longer talk to my MacBook wirelessly -- Help?

    After downloading a new version of Firefox, my MacBook quit talking to my printer.  I've reinstalled printer software and run a Wireless Network Test Report & Configuration Page.  The printer still tells me that mly printer is off-line.  Has anyone e

  • Disk Utility can't repair this disk

    I have been having trouble booting. It started when I connected a router to it. It seemed to eat up the free disk space and I only have 77 MB left or something around that. Anyway, I tried deleting files with command-s commands, and it worked one tim

  • Adobe pdf reader active-x on a single processor

    I am using Adobe Reader version 9.3.3 on a Windows XP Pro SP3 Dual Core machine and it does work as a standalone application perfectly fine, however, I have embedded the ActiveX control that comes with this install into a 3rd party application so I c

  • Delete duplicate songs itunes on a mac

    Can someone tell me how to remove duplicate songs from my mac. I saw several threads where a script had been written for a pc, surely there's an easy way to remove the duplicates and keep the original. Thanks for your time.

  • Copying of price for Service PO

    Hi Friends,                     While creating po, price is triggering from last PO. But I don't want to copy from any previous data. I want to copy from PR for Services only for rest of PO's , price has to be fetched from last PO. So how to control