Stored procedure for disabling all foreign key constraints ?

hi all,
I need a stored procedure for disabling / enable all constraints in that database schema.
Create or replace procedure enable_disable_proc(status varchar2(3),schema_name varchar2(20))
---> where 'status' parameter condition should be ( YES for enable) (NO for disable)
---> 'schema_name' is a parameter where ,only this schema should be affected with this procedure..
Thanks in Advance..

Hi,
Try this code
/* Formatted on 2009/07/16 08:15 (Formatter Plus v4.8.8) */
CREATE PROCEDURE enab_disab_proc (
   enforce          IN   VARCHAR2,
   current_schema   IN   VARCHAR2
IS
   v_alter_table_sql   VARCHAR2 (2000);
BEGIN
   FOR rec_con IN (SELECT table_name, constraint_name
                     FROM user_constraints
                    WHERE owner = current_schema)
   LOOP
      IF (enforce = 'NO')
      THEN
         v_alter_table_sql :=
               ' alter table '
            || current_schema
            || '.'
            || rec_con.table_name
            || ' disable constraint '
            || rec_con.constraint_name;
      ELSE
         v_alter_table_sql :=
               ' alter table '
            || current_schema
            || '.'
            || rec_con.table_name
            || ' enable constraint '
            || rec_con.constraint_name;
      END IF;
      EXECUTE IMMEDIATE v_alter_table_sql;
   END LOOP;
END;Edited by: Salim Chelabi on 2009-07-16 05:15

Similar Messages

  • Import table data in right order to avoid violating foreign key constraints

    Gentlemen
    I am trying to import table data into an existing 10g schema using datapump import in table mode.
    However, in order to avoid violating foreign key constraints, the tables must be loaded in a specified order. I tried specifying the order in the TABLES parameter:
    TABLES=table1,table2,table3 etc.
    However, datapump seems to chose its own order leading to errors like the following:
    ORA-31693: Table data object "SCHEMAX"."TABLE3" failed to load/unload and is being skipped due to error:
    ORA-02291: integrity constraint (SCHEMAX.TABLE3_TABLE1#FK) violated - parent key not found
    I want to try to avoid having to disable all foreign keys because there are hundreds of them.
    Any advice?
    Yours
    Claus Jacobsen, Denmark

    Thanks Anantha.
    Since I am only loadding data (the constraints are already defined in the target database), I am not sure whether this approach would work. Meanwhile I have solved the problem of moving data from one system to another using another, tedious and far from elegant approach that I would prefer to not eloborate on:-)
    However, I have also discovered another probable reason why the foreign key constraints were violated, other than wrong order of table data loading. It turns out almost every single table in the schema contains a trigger supposed to generate a unique row ID from a sequence on insert such as:
    CREATE OR REPLACE TRIGGER "SCHEMAX"."TABLEX#B_I_R"
    BEFORE INSERT
    ON TABLEX
    FOR EACH ROW
    DECLARE
    BEGIN
    SELECT tablex_seq.nextval INTO :NEW.ID FROM dual;
    END;
    If the import mechanism fires this trigger, and the sequences in the source and the target systems are not synchronized, then I guess that referred records a more than likely to end up with wrong ID's compared to the row ID's in the referring rows?
    Spooky. Anybody can confirm this theory?
    Yours
    Claus
    Message was edited by:
    user586249

  • Publish: dropping index when it is used for foreign key constraint enforcement

    Hi,
    I'm trying to update a target schema from a reference database via Publish. Among the changes to apply, there's an index that needs to be dropped. Since it's linked to a foreign key constraint, it cannot be deleted unless the foreign key is temporarily dropped
    (I saw somewhere that disabling the foreign key should be enough but it doesn't seem to work either).
    Since there are other changes to be made on the same table, this foreign key also has to be dropped before the script can delete the table and re-create it. This part of the script is correctly generated. The problem is that this part appears after the 'DROP
    INDEX' instruction.
    So when generating the update script, SSDT tries to drop the index BEFORE dropping the foreign key. And I can't drop the foreign key in my custom pre-deployment script, otherwise the update script would fail when trying to delete it again.
    Shouldn't SSDT be smart enough to drop the constraint before the index? Is it a bug or did I forget to set an option? If it's not a bug, what can I do apart from doing it manually?
    Thank you for your help

    Hi Elsa,
    That sounds like a bug. Could you please file a Connect issue for this at
    https://connect.microsoft.com/SQLServer/feedback/CreateFeedback.aspx using the category "Developer Tools (SSDT, BIDS, etc.)"? We're trying to track all bugs through
    Connect so that you can tell when we have fixed the issue and we can request more information.
    A workaround for this issue might be to write a pre-deployment script for your project to drop the foreign key prior to deployment. A pre-deployment script can be added to your project by right-clicking on the
    project in solution explorer and then clicking on Add > Script... and selecting Pre-Deployment Script from the list.
    Thanks!

  • Primary Key and Foreign Key Constraints

    Hi All,
    I would like to know PRIMARY KEY and FOREIGN KEY constraints on existing oracle tables. Could any one suggest me how to find out.
    Thanks,
    RED

    You can query DBA_CONSTRAINTS to get a list of all the constraints on table A and/or table B. The documentation I linked to gives a full list of the data you can see in DBA_CONSTRAINTS, but it includes things like the referenced table name and referenced constraint name for a foreign key constraint. If A is a parent of B or B is a parent of A, you could match up the parent's primary key constraint to the child's foreign key constraint.
    More generally, though, if you don't know that one of the tables is a parent of the other, figuring out how to join the two tables is probably not something that can be done using just the Oracle data dictionary. You would probably need an understanding of the data model being used to figure out what intermediate table(s) needed to be joined in order to relate rows in A to rows in B.
    Justin

  • Using FOreign key constraints on tables in database.

    I am student and novice in the field of ORACLE and PL/SQL and Database Creation. I had created a database consisting tables and got problem while applying foreign key constraints.
    CUST_MSTR
    CREATE TABLE "DBA_BANKSYS"."CUST_MSTR"("CUST_NO" VARCHAR2(10),
    "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25), "LNAME" VARCHAR2(25),
    "DOB_INC" DATE NOT NULL,      "OCCUP" VARCHAR2(25), "PHOTOGRAPH" VARCHAR2(25),
    "SIGNATURE" VARCHAR2(25), "PANCOPY" VARCHAR2(1),      "FORM60" VARCHAR2(1));
    (CUST_NO is PRIMARY KEY, )
    -- EMP_MSTR
    CREATE TABLE "DBA_BANKSYS"."EMP_MSTR"("EMP_NO" VARCHAR2(10),
    "BRANCH_NO" VARCHAR2(10), "FNAME" VARCHAR2(25), "MNAME" VARCHAR2(25),
    "LNAME" VARCHAR2(25), "DEPT" VARCHAR2(30), "DESIG" VARCHAR2(30));
    (EMP_NO is primary key )
    --NOMINEE_MSTR
    CREATE TABLE "DBA_BANKSYS"."NOMINEE_MSTR"("NOMINEE_NO" VARCHAR2(10),
    "ACCT_FD_NO" VARCHAR2(10), "NAME" VARCHAR2(75), "DOB" DATE,
    RELATIONSHIP" VARCHAR2(25));
    (NOMINEE_NO is primary key )
    --ADDR_DTLS
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6));
    ( ADDR_NO is primary key )
    Problem: I want to apply foreign key constraints on ADDR_DTLS table so that Before inserting value in ADDR_DTLS table it must check, VALUE in ADDR_DTLS.CODE_NO must be PRESENT either in attribute value CUST_MSTR.CODE_NO or EMP_MSTR.CODE_NO or NOMINEE_MSTR.CODE_NO table .
    I applied the foreign key constraints using this syntax
    CREATE TABLE "DBA_BANKSYS"."ADDR_DTLS"("ADDR_NO" NUMBER(6),
    "CODE_NO" VARCHAR2(10),      "ADDR_TYPE" VARCHAR2(1), "ADDR1" VARCHAR2(50),
    "ADDR2" VARCHAR2(50), "CITY" VARCHAR2(25), "STATE" VARCHAR2(25),
    "PINCODE" VARCHAR2(6),
    constraints fk_add foreign key CODE_NO references CUST_MSTR. CODE_NO,
    constraints fk_add1 foreign key CODE_NO references EMP_MSTR. CODE_NO,
    constraints fk_add2 foreign key CODE_NO references NOMINEE_MSTR.CODE_NO);
    (foreign key)
    ADDR_DTLS.CODE_NO ->CUST_MSTR.CUST_NO
    ADDR_DTLS.CODE_NO ->NOMINEE_MSTR.NOMINEE_NO
    ADDR_DTLS.CODE_NO ->BRANCH_MSTR.BRANCH_NO
    ADDR_DTLS.CODE_NO ->EMP_MSTR.EMP_NO
    When I applied foreign key constraints this way, its gives a error called foreign key constraints violation. (I understand that, its searches the attribute value of ADDR_DTLS.CODE_NO in all the three tables must be present then the value will be inserted. But I want, if the value is in any of the three table then its should insert the value or its gives an error.)
    Please help me out, though i put the question and i want too know how to apply the forign key in this way. and is there any other option if foreign key implementation is not pssible.

    If you are on 11g you can use ON DELETE SET NULL:
    CREATE TABLE addr_dtls
    ( addr_no          NUMBER(6)  CONSTRAINT addr_pk PRIMARY KEY
    , addr_cust_no     CONSTRAINT addr_cust_fk    REFERENCES cust_mstr    ON DELETE SET NULL
    , addr_emp_no      CONSTRAINT addr_emp_fk     REFERENCES emp_mstr     ON DELETE SET NULL
    , addr_nominee_no  CONSTRAINT addr_nominee_fk REFERENCES nominee_mstr ON DELETE SET NULL
    , addr_type        VARCHAR2(1)
    , addr1            VARCHAR2(50)
    , addr2            VARCHAR2(50)
    , city             VARCHAR2(25)
    , state            VARCHAR2(25)
    , pincode          VARCHAR2(6) );In earlier versions you'll need to code some application logic to do something similar when a parent row is deleted, as otherwise the only options are to delete the dependent rows or raise an error.
    btw table names can be up to 30 characters and don't need to end with MSTR or DTLS, so for example CUSTOMERS and ADDRESSES might be more readable than CUST_MSTR and ADDR_DTLS. Also if the Customer/Employee/Nominee PKs are generated from a sequence they should be numeric.
    Edited by: William Robertson on Aug 15, 2010 6:47 PM

  • Foreign Key Constraint Failure on Self-Referencing Table

    In a recent data deletion project, I ran into a problem where Oracle allowed for a record (the parent) to be deleted when there still existed a child record in the same table which referred to the parent.
    An abbreviated version of the table is as follows:
    create table test (
    template_id number not null,
    customer_id number null,
    parent_id number null,
    constraint pk_test primary key (template_id),
    constraint r_parent foreign key (parent_id) references test (template_id));
    The parent and child records are as follows:
    Parent: template_id = 100, customer_id = 200, parent_id = null
    Child: template_id = 101, customer_id = null, parent_id = 100
    Records were deleted from this table using:
    DELETE FROM test WHERE customer_id = 200;
    When this statement is executed, is it being executed as part of 155 delete statements using PL/SQL, and tens of thousands of records from 155 tables are being deleted. These delete statements have been ordered taking into account foreign key constraints. All 155 statements are being deleted in a single transaction. The delete statement above was the 23rd statement of the set to be executed. I would have expected when this delete statement was executed, an error would have been thrown. However, all 155 delete statements successfully complete, and after committing the results, the child record above still exists in the DB as an orphan. I also tried executing the first 23 statements manually in SQL*Plus (still one transaction), and the problem still occurs: the parent is deleted and the child is orphaned.
    If I execute the very simple example above, I do indeed get an referential constraint error.
    Has anyone ever encountered this situation? And does anyone have any ideas how to go about troubleshooting this problem. We need to know the cause of this, as we have a small handful of table with a similar self-referential foreign key constraint set-up.
    Thank you very much in advance,
    Mark

    First of all, the very simple example that I outlined above I have already tried and it worked: when I attempted to delete the parent a referential integrity error was thrown as one would expect. This small example was my test case to see if I could reproduce what I'm seeing in our application in a more manageable and demonstrable example. But as it worked, I'm still perplexed in reconciling the differences between what I'm seeing in our application (which I can't demonstrate in this help group) and the test case. When I used the test case in my first posting in this thread, I used it to help describe the problem I'm encountered, even though that small example works.
    Below is more of the table you've asked for.
    OWNER           CONSTRAINT_NAME          CONSTRAINT_TYPE     TABLE_NAME     SEARCH_CONDITION     R_OWNER            R_CONSTRAINT_NAME     DELETE_RULE     STATUS          DEFERRABLE            DEFERRED         VALIDATED     GENERATED     BAD     RELY     LAST_CHANGE           INDEX_OWNER  INDEX_NAME       INVALID     VIEW_RELATED
    "DOCPADMIN"     "R_TEMPLATE_PARENT"     "R"             "DCR_TEMPLATE"      (null)                  "DOCPADMIN"     "XPKDCR_TEMPLATE"     "NO ACTION"  "ENABLED"   "NOT DEFERRABLE"    "IMMEDIATE"  "VALIDATED"      "USER NAME"     (null)     (null)     "2010-01-13 19:01:21"     (null)        (null)         (null)       (null)
    "DOCPADMIN"     "XPKDCR_TEMPLATE"       "P"             "DCR_TEMPLATE"      (null)                       (null)     (null)                      (null)          "ENABLED"     "NOT DEFERRABLE"    "IMMEDIATE"      "VALIDATED"     "USER NAME"     (null)     (null)     "2010-01-13 15:48:31"     (null)     "XPKDCR_TEMPLATE"   (null)     (null)Overall, I haven't said that Oracle's FK mechanism is broken. What I've said is that I've got a situation that I'm trying to understand. My first attempt at my test case didn't work because the test case worked as it should. I'm trying to figure out another course of action to try and figure this situation out.

  • Wrong order foreign key constraints

    Hi,
    i have problems with non-deferred foreing key constraints:
    I have a table "PERSON" and a table "ADRESSE" which has a foreign key
    to "PERSON". Both tables have primary keys with two columns.
    In the mappings I use application identity. The mappings are generated by
    xdoclet.
    We cannot use deferred constraint because we have to support following
    databases: Oracle, Firebird, MS SQL, DB2.
    I tested the mappings with Oracle and Firebird and got this exception
    (with SQL Trace):
    5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (1 errors)>
    [15 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
    04941 183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751,
    (String) Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null,
    (String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]
    5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
    [0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12764,
    (int) 1, (int) 0, (null) null, (String) Sylt, (int) 12759, (String) 25980,
    (int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
    [reused=1]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
    [0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
    KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
    PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
    null, (int) 12759, (String) 9999452800, (null) null, (int) 1, (String)
    Horstmann, (String) Manfred, (Timestamp) 1959-03-10 00:00:00.381, (String)
    Flensburg, (int) 1] [reused=0]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
    [0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
    04941 183742, (int) 12763, (int) 1, (int) 1, (String) 0171 2846751,
    (String) Oldenburg, (int) 12759, (String) 26129, (int) 1, (null) null,
    (String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=2]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12762,
    (int) 1, (int) 0, (null) null, (String) Sylt, (int) 12760, (String) 25980,
    (int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
    [reused=3]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
    KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
    PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
    null, (int) 12760, (String) 9999452801, (null) null, (int) 1, (String)
    Horstmann, (String) Christine, (Timestamp) 1972-03-10 00:00:00.381,
    (String) Erfurt, (int) 1] [reused=1]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
    (ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
    FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
    IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
    STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
    [params=(int) 0, (null) null, (double) 0.0, (null) null, (int) 12410,
    (int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
    3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12760,
    (int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
    null] [reused=0]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
    (ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
    FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
    IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
    STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
    [params=(int) 0, (null) null, (double) 0.0, (int) 12362, (int) 12378,
    (int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
    3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12759,
    (int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
    null] [reused=1]
    5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
    errors)> [16 ms] rollback
    5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
    errors)> return
    5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
    errors)> [0 ms] close
    com.solarmetric.jdbc.ReportingSQLException: ORA-02291: integrity
    constraint (VAMP.ADRESSE_PS) violated - parent key not found
    {prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART, EMAIL, FAXNR,
    ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ, POSTADRESSE,
    POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?) [params=(int) 1, (String) [email protected], (String) 04941
    183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751, (String)
    Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null, (String)
    Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]} [code=2291,
    state=23000]
         at
    com.solarmetric.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:124)
         at
    com.solarmetric.jdbc.LoggingConnectionDecorator.access$600(LoggingConnectionDecorator.java:19)
         at
    com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:728)
         at
    com.solarmetric.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:362)
    How can I force it to insert in the table "NATPERSON" first and then in
    the table "ADRESSE"?
    I use following JDBC-drivers:
    Firebird: 1.5.5
    Oracle: 9.2.0.1.0
    My property file:
    <!-- standard properties for all dbms -->
    <prop key="kodo.LicenseKey">LICENSE KEY REMOVED</prop>
    <prop key="kodo.ConnectionFactoryProperties">MaxCachedStatements=150,
    MaxActive=50, MaxIdle=50</prop>
    <prop key="kodo.FetchBatchSize">200</prop>
    <prop key="kodo.DataCache">true(CacheSize=5000)</prop>
    <prop key="kodo.RemoteCommitProvider">sjvm</prop>
    <prop key="kodo.jdbc.MappingFactory">metadata</prop>
    <prop key="kodo.jdbc.ForeignKeyConstraints">true</prop>
    <prop key="kodo.jdbc.SchemaFactory">native</prop>
    <prop
    key="javax.jdo.PersistenceManagerFactoryClass">kodo.jdbc.runtime.JDBCPersistenceManagerFactory</prop>
    <prop key="javax.jdo.option.Optimistic">true</prop>
    <!-- oracle connection properties -->
    <prop key="kodo.jdbc.DBDictionary">oracle</prop>
    <prop
    key="javax.jdo.option.ConnectionDriverName">oracle.jdbc.driver.OracleDriver</prop>
    <prop key="javax.jdo.option.ConnectionURL">..</prop>
    <prop key="javax.jdo.option.ConnectionUserName">..</prop>
    <prop key="javax.jdo.option.ConnectionPassword">..</prop>
    <prop key="kodo.jdbc.SequenceFactory">native</prop>
    <prop key="kodo.jdbc.Schemas">..</prop>
    <!-- firebird connection properties
    <prop key="kodo.jdbc.DBDictionary">kodo.jdbc.sql.FirebirdDictionary</prop>
    <prop
    key="javax.jdo.option.ConnectionDriverName">org.firebirdsql.jdbc.FBDriver</prop>
    <prop key="javax.jdo.option.ConnectionURL">..</prop>
    <prop key="javax.jdo.option.ConnectionUserName">..</prop>
    <prop key="javax.jdo.option.ConnectionPassword">..</prop>
    <prop key="kodo.jdbc.SequenceFactory">native(TableName=SYSDUAL,
    Format="SELECT GEN_ID({0},1) FROM {1}")</prop>
    -->
    My database schema looks like this:
    TABLE PERSON
    FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
    FIELD ID (AUTOINC COMMENT (""))
    FIELD TYP (SMALLINT REQUIRED COMMENT (""))
    FIELD KUNDENNR (CHAR(15) COMMENT ("Kundennummer"))
    PRIMARY KEY
    FIELD MANDANTID
    FIELD ID
    FOREIGN KEY MD
    TABLE MANDANT
    FIELD MANDANTID
    INDEX KDNR
    FIELD MANDANTID
    FIELD KUNDENNR
    UNIQUE
    TABLE ADRESSE
    FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
    FIELD ID (AUTOINC COMMENT (""))
    FIELD PERSONID (LONGINT REQUIRED COMMENT (""))
    PRIMARY KEY
    FIELD MANDANTID
    FIELD ID
    FOREIGN KEY PS
    TABLE PERSON
    FIELD MANDANTID
    FIELD PERSONID
    My metadata looks like this:
    <class name="PersonDO"
    identity-type="application"
    objectid-class="com.elaxy.vamp.dom.person.PersonDOId"
    persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
    <extension vendor-name="kodo"
    key="jdbc-class-ind"
    value="metadata-value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-ind/column"
    value="TYP">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-ind-value"
    value="-1">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map"
    value="base">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map/table"
    value="PERSON">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
    value="ID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
    value="MANDANTID">
    </extension>
    <field name="kundenNr"
    persistence-modifier="persistent">
    </field>
    <field name="adressen"
    persistence-modifier="persistent">
    <collection
    element-type="com.elaxy.vamp.dom.person.AdresseDO">
    </collection>
    <extension vendor-name="kodo"
    key="jdbc-field-map"
    value="one-many">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-map/ref-column.MANDANTID"
    value="MANDANTID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-map/ref-column.ID"
    value="PERSONID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-map/table"
    value="ADRESSE">
    </extension>
    </field>
    .. fields ..
    </class>
    <class name="AdresseDO"
    identity-type="application"
    objectid-class="com.elaxy.vamp.dom.person.AdresseDOId"
    persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
    <extension vendor-name="kodo"
    key="jdbc-class-map"
    value="base">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map/table"
    value="ADRESSE">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-sequence-name"
    value="ADRESSE_SEQ">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
    value="ID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
    value="MANDANTID">
    </extension>
    .. fields ..
    </class>
    Many thanks,
    Jan

    Marc
    This is a part of the output from the "schemagen" tool:
    <schemas>
    <schema name="VAMP">
    <table name="ADRESSE">
    <pk name="ADRESSE_PRIMARY">
    <on column="ID"/>
    <on column="MANDANTID"/>
    </pk>
    <column name="ADRESSART" type="decimal" type-name="NUMBER"
    size="5"/>
    <column name="EMAIL" type="varchar" type-name="VARCHAR2"
    size="30"/>
    <column name="FAXNR" type="varchar" type-name="VARCHAR2"
    size="25"/>
    <column name="ID" type="decimal" type-name="NUMBER"
    not-null="true" size="10"/>
    <column name="LAND" type="decimal" type-name="NUMBER"
    size="10"/>
    <column name="MANDANTID" type="decimal" type-name="NUMBER"
    not-null="true" size="5"/>
    <column name="MELDEADRESSE" type="decimal" type-name="NUMBER"
    size="1"/>
    <column name="MOBILNR" type="varchar" type-name="VARCHAR2"
    size="25"/>
    <column name="ORT" type="varchar" type-name="VARCHAR2"
    size="30"/>
    <column name="PERSONID" type="decimal" type-name="NUMBER"
    not-null="true" size="10"/>
    <column name="PLZ" type="varchar" type-name="VARCHAR2"
    size="5"/>
    <column name="POSTADRESSE" type="decimal" type-name="NUMBER"
    size="1"/>
    <column name="POSTFACH" type="varchar" type-name="VARCHAR2"
    size="10"/>
    <column name="STRASSE" type="varchar" type-name="VARCHAR2"
    size="30"/>
    <column name="TELEFONNR" type="varchar" type-name="VARCHAR2"
    size="25"/>
    <fk name="ADRESSE_PS" delete-action="cascade"
    to-table="VAMP.PERSON">
    <join column="MANDANTID" to-column="MANDANTID"/>
    <join column="PERSONID" to-column="ID"/>
    </fk>
    <index name="ADRESSE_ORT">
    <on column="MANDANTID"/>
    <on column="ORT"/>
    </index>
    <index name="ADRESSE_PLZ">
    <on column="MANDANTID"/>
    <on column="PLZ"/>
    </index>
    <index name="ADRESSE_PS">
    <on column="MANDANTID"/>
    <on column="PERSONID"/>
    </index>
    <index name="ADRESSE_STR">
    <on column="MANDANTID"/>
    <on column="STRASSE"/>
    </index>
    </table>
    The foreign key "ADRESSE_PS" was identified correctly.
    I've taken a look at the class OracleDictionary and it seems that the
    object "ForeignKey" considers only one column from the foreign keys -
    but I use foreign keys that include two columns ("MANDANTID", "PERSONID").
    Is that right or are foreign keys with two columns allowed by the
    OracleDictionary?
    Marc Prud'hommeaux wrote:
    Jan-
    That is odd ... Kodo should be identifying the foreign keys and ordering
    the statements accordingly. The mappings appear correct to me at first
    glance. If you run the "schemagen" tool, does Kodo correctly identify
    the foreign key constraints in the database? Can you post the output
    from the command so we can take a look?
    Jan-Esdert Franken wrote:
    Hi,
    i have problems with non-deferred foreing key constraints:
    I have a table "PERSON" and a table "ADRESSE" which has a foreign key
    to "PERSON". Both tables have primary keys with two columns.
    In the mappings I use application identity. The mappings are generated by
    xdoclet.
    We cannot use deferred constraint because we have to support following
    databases: Oracle, Firebird, MS SQL, DB2.
    I tested the mappings with Oracle and Firebird and got this exception
    (with SQL Trace):
    5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (1 errors)>
    [15 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
    04941 183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751,
    (String) Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null,
    (String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]
    5602 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
    [0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12764,
    (int) 1, (int) 0, (null) null, (String) Sylt, (int) 12759, (String) 25980,
    (int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
    [reused=1]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
    [0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
    KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
    PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
    null, (int) 12759, (String) 9999452800, (null) null, (int) 1, (String)
    Horstmann, (String) Manfred, (Timestamp) 1959-03-10 00:00:00.381, (String)
    Flensburg, (int) 1] [reused=0]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (2 errors)>
    [0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 1, (String) [email protected], (String)
    04941 183742, (int) 12763, (int) 1, (int) 1, (String) 0171 2846751,
    (String) Oldenburg, (int) 12759, (String) 26129, (int) 1, (null) null,
    (String) Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=2]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART,
    EMAIL, FAXNR, ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ,
    POSTADRESSE, POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?, ?, ?, ?, ?) [params=(int) 3, (null) null, (null) null, (int) 12762,
    (int) 1, (int) 0, (null) null, (String) Sylt, (int) 12760, (String) 25980,
    (int) 0, (null) null, (String) Stephanstra__e 47, (String) 04651 19283]
    [reused=3]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 13390902 INSERT INTO VAMP.PERSON (ANREDEID, ID,
    KUNDENNR, LOESCHBEMERKUNG, MANDANTID, NAME1, NAME2, PERSONENDATUM,
    PERSONENORT, TYP) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [params=(null)
    null, (int) 12760, (String) 9999452801, (null) null, (int) 1, (String)
    Horstmann, (String) Christine, (Timestamp) 1972-03-10 00:00:00.381,
    (String) Erfurt, (int) 1] [reused=1]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
    (ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
    FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
    IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
    STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
    [params=(int) 0, (null) null, (double) 0.0, (null) null, (int) 12410,
    (int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
    3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12760,
    (int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
    null] [reused=0]
    5618 TRACE [main] kodo.jdbc.SQL - <t 26577913, conn 33108879 (3 errors)>
    [0 ms] executing prepstmnt 11320634 INSERT INTO VAMP.NATPERSON
    (ANZAHLKINDER, ARBEITGEBERID, BEITRAGSSATZ, BERUFID, BRANCHEID,
    FAMILIENSTAND, FAMSTANDSEIT, FINANZAMTID, GEBIETSFREMDERAWG, GUETERSTAND,
    IDBEHOERDE, IDNR, KIRCHENSTEUER, KVID, MANDANTID, PERSONID, PRIVATKV,
    STAAT, STEUERBERATERID, STEUERKLASSE, STEUERNR, STEUERTARIF, TITEL) VALUES
    [params=(int) 0, (null) null, (double) 0.0, (int) 12362, (int) 12378,
    (int) 2, (Timestamp) 1991-12-12 00:00:00.381, (null) null, (int) 0, (int)
    3, (null) null, (null) null, (int) 0, (int) 12576, (int) 1, (int) 12759,
    (int) 0, (null) null, (null) null, (int) 0, (null) null, (int) 1, (null)
    null] [reused=1]
    5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
    errors)> [16 ms] rollback
    5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
    errors)> return
    5634 TRACE [main] kodo.jdbc.JDBC - <t 26577913, conn 33108879 (3
    errors)> [0 ms] close
    com.solarmetric.jdbc.ReportingSQLException: ORA-02291: integrity
    constraint (VAMP.ADRESSE_PS) violated - parent key not found
    {prepstmnt 22511833 INSERT INTO VAMP.ADRESSE (ADRESSART, EMAIL, FAXNR,
    ID, MANDANTID, MELDEADRESSE, MOBILNR, ORT, PERSONID, PLZ, POSTADRESSE,
    POSTFACH, STRASSE, TELEFONNR) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?,
    ?, ?) [params=(int) 1, (String) [email protected], (String) 04941
    183742, (int) 12761, (int) 1, (int) 1, (String) 0171 2846751, (String)
    Oldenburg, (int) 12760, (String) 26129, (int) 1, (null) null, (String)
    Ammerl__nder Heerstra__e 19, (String) 04941 183740] [reused=0]} [code=2291,
    state=23000]
         at
    com.solarmetric.jdbc.LoggingConnectionDecorator.wrap(LoggingConnectionDecorator.java:124)
         at
    com.solarmetric.jdbc.LoggingConnectionDecorator.access$600(LoggingConnectionDecorator.java:19)
         at
    com.solarmetric.jdbc.LoggingConnectionDecorator$LoggingConnection$LoggingPreparedStatement.executeUpdate(LoggingConnectionDecorator.java:728)
         at
    com.solarmetric.jdbc.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:362)
    How can I force it to insert in the table "NATPERSON" first and then in
    the table "ADRESSE"?
    I use following JDBC-drivers:
    Firebird: 1.5.5
    Oracle: 9.2.0.1.0
    My property file:
    <!-- standard properties for all dbms -->
    <prop key="kodo.LicenseKey">LICENSE KEY REMOVED</prop>
    <prop key="kodo.ConnectionFactoryProperties">MaxCachedStatements=150,
    MaxActive=50, MaxIdle=50</prop>
    <prop key="kodo.FetchBatchSize">200</prop>
    <prop key="kodo.DataCache">true(CacheSize=5000)</prop>
    <prop key="kodo.RemoteCommitProvider">sjvm</prop>
    <prop key="kodo.jdbc.MappingFactory">metadata</prop>
    <prop key="kodo.jdbc.ForeignKeyConstraints">true</prop>
    <prop key="kodo.jdbc.SchemaFactory">native</prop>
    <prop
    key="javax.jdo.PersistenceManagerFactoryClass">kodo.jdbc.runtime.JDBCPersistenceManagerFactory</prop>
    <prop key="javax.jdo.option.Optimistic">true</prop>
    <!-- oracle connection properties -->
    <prop key="kodo.jdbc.DBDictionary">oracle</prop>
    <prop
    key="javax.jdo.option.ConnectionDriverName">oracle.jdbc.driver.OracleDriver</prop>
    <prop key="javax.jdo.option.ConnectionURL">..</prop>
    <prop key="javax.jdo.option.ConnectionUserName">..</prop>
    <prop key="javax.jdo.option.ConnectionPassword">..</prop>
    <prop key="kodo.jdbc.SequenceFactory">native</prop>
    <prop key="kodo.jdbc.Schemas">..</prop>
    <!-- firebird connection properties
    <prop key="kodo.jdbc.DBDictionary">kodo.jdbc.sql.FirebirdDictionary</prop>
    <prop
    key="javax.jdo.option.ConnectionDriverName">org.firebirdsql.jdbc.FBDriver</prop>
    <prop key="javax.jdo.option.ConnectionURL">..</prop>
    <prop key="javax.jdo.option.ConnectionUserName">..</prop>
    <prop key="javax.jdo.option.ConnectionPassword">..</prop>
    <prop key="kodo.jdbc.SequenceFactory">native(TableName=SYSDUAL,
    Format="SELECT GEN_ID(,1) FROM ")</prop>
    -->
    My database schema looks like this:
    TABLE PERSON
    FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
    FIELD ID (AUTOINC COMMENT (""))
    FIELD TYP (SMALLINT REQUIRED COMMENT (""))
    FIELD KUNDENNR (CHAR(15) COMMENT ("Kundennummer"))
    PRIMARY KEY
    FIELD MANDANTID
    FIELD ID
    FOREIGN KEY MD
    TABLE MANDANT
    FIELD MANDANTID
    INDEX KDNR
    FIELD MANDANTID
    FIELD KUNDENNR
    UNIQUE
    TABLE ADRESSE
    FIELD MANDANTID (SMALLINT REQUIRED COMMENT (""))
    FIELD ID (AUTOINC COMMENT (""))
    FIELD PERSONID (LONGINT REQUIRED COMMENT (""))
    PRIMARY KEY
    FIELD MANDANTID
    FIELD ID
    FOREIGN KEY PS
    TABLE PERSON
    FIELD MANDANTID
    FIELD PERSONID
    My metadata looks like this:
    <class name="PersonDO"
    identity-type="application"
    objectid-class="com.elaxy.vamp.dom.person.PersonDOId"
    persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
    <extension vendor-name="kodo"
    key="jdbc-class-ind"
    value="metadata-value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-ind/column"
    value="TYP">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-ind-value"
    value="-1">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map"
    value="base">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map/table"
    value="PERSON">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
    value="ID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
    value="MANDANTID">
    </extension>
    <field name="kundenNr"
    persistence-modifier="persistent">
    </field>
    <field name="adressen"
    persistence-modifier="persistent">
    <collection
    element-type="com.elaxy.vamp.dom.person.AdresseDO">
    </collection>
    <extension vendor-name="kodo"
    key="jdbc-field-map"
    value="one-many">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-map/ref-column.MANDANTID"
    value="MANDANTID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-map/ref-column.ID"
    value="PERSONID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-map/table"
    value="ADRESSE">
    </extension>
    </field>
    .. fields ..
    </class>
    <class name="AdresseDO"
    identity-type="application"
    objectid-class="com.elaxy.vamp.dom.person.AdresseDOId"
    persistence-capable-superclass="com.elaxy.vamp.dom.AbstractDO">
    <extension vendor-name="kodo"
    key="jdbc-class-map"
    value="base">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-class-map/table"
    value="ADRESSE">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-sequence-name"
    value="ADRESSE_SEQ">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.id/jdbc-field-map/column"
    value="ID">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId"
    value="">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map"
    value="value">
    </extension>
    <extension vendor-name="kodo"
    key="jdbc-field-mappings/AbstractDO.mandantId/jdbc-field-map/column"
    value="MANDANTID">
    </extension>
    .. fields ..
    </class>
    Many thanks,
    Jan
    Marc Prud'hommeaux
    SolarMetric Inc.

  • Generated Script fails when attempting to drop Foreign Key Constraint

    I made some changes to my database.  I used the generate script process to generate a drop and create script to these tables.  The generated script first ran Alter Table Drop Constraints to drop the Foreign Key constraints and then did Drop tables
    and then did create table to construct the script with the proper changes.
    However, when we attempted to run the script, all of the Drop constraint statements failed reporting that there was no such constraint.  Then the drop table scripts failed because of the existence of the very foreign key constraints  that SQL Server
    had just stated did not exist.
    BOL states that the statement "DROP { [ CONSTRAINT ] constraint_name | COLUMN column_name } " is  "Used in a CHECK, FOREIGN KEY, UNIQUE, or PRIMARY KEY constraint."  So why couldn't I drop those specified Foreign
    Key constraints in a script generated by SQL Server itself.
    Edward R. Joell MCSD MCDBA

    Are you sure there are no Constraints on other tables which are causing your issue?
    If a foreign key from table abc refences table def it will cause the drop to fail.
    If your script is already attempting to drop such constraints, have you checked that they are dropping from the correct table (and not the table that would be the target of the drop)?
    I discovered two things yesterday and one thing today about generated scripts.
    When you generated a script to drop and create a set of tables and you mark it to include foreign keys, the generated script will first create a set a scripts to drop the foreign keys , then will create a set of statements for each table that will,
    first, again drop the same foreign keys that it did earlier, then drop the table.  If there is no "if exists" statement for each statement, the drop constraint will fail.
    The script generated by the generate scripts wizard, even when you set the Drop and Create option in the advanced tab, unlike the scripts generated when you right click a table and select Drop and Create from the context menu, does not by default create
    an "If Exists" statement before the attempt to drop anything.
    You can make the generate Scripts wizard generate an "if exists" statement by changing the "Include if NOT EXISTS" option on the advanced tab to true. However, while the script generator will find all of the foreign keys that show that
    table as the parent_id, it will not show the FK constraints on tables which are not being dropped and created.  Nor can you find them by querying the sys.foreign_keys view using the standard type of Foreign Key "If Exists" statement because
    it would do a query like
    SELECT *
    FROM sys.foreign_keys
    WHERE object_id = OBJECT_ID(N'[dbo].[FK_prc_ContractSubLines_prc_PRSubLines]')
    AND parent_object_id = OBJECT_ID(N'[dbo].[prc_ContractSubLines]')
    And the script generator does not care even if you show an option like "Generate Scripts For Dependent Objects", it will not generate a drop script for the foreign constraints on other tables that reference your table.  I have not even found
    a way to get back the results of a query on the sys.foreign_keys view that will show those keys that reference your table. The only thing I been able to do is to open the table in design and check out the list of relationships in your table and see open each
    relationship and see which table is the "foreign key table" rather than the primary key table. This will make writing drop and create scripts very very long and tedious. As you would have to  create addional Alter tables scripts to do a drop
    and create foreign keys on each table referencing yours and manually place them into your scripts at correct locations. This is almost as bad as the Oracle SQL Developer's generate script results which (at least in 2010) so screws up the order of the generated
    script that it is trying to create foreign keys on tables it has not created yet.
    So Patrick I see that you thought about the foreign keys on other tables.  I wish I had read your post before spending the morning troubleshooting this issue based on this morning's script that ran and crashed embarrassingly. 
    I would like to know if someone has a query to reveal all of the foreign keys that reference your table from another table using the sys views.  As it is I have to open each table in design to get a list of FKs that reference it.
    Edward R. Joell MCSD MCDBA

  • Stored Procedure for Accounts Receivable

    Hi. First off, apologies in advance if I have put this question into the wrong topic. Secondly, I first saw SAP 3 weeks ago when I stared my new job and have had no training so please bear with me if some of what I ask doesn't make much sense.
    OK, the issue is this.  In SAP B1, there is a built in Report called "Customer Receivables Aging" which allows you to see Customer Receivable Accounts by age (e.g 0-30, 31-60, 61-90, 90+) and so on.  The problem with the built in report is that it doesn't show all the fields I want - it only shows the Customer Name, balance, and then the aging balances.  I want to be able to see things like the customer's contact details, etc. I know this makes no sense because the whole point of the report is to be able to drill down into the different rows, but this report needs to be issued in printed form, hence the need for the extra fields.
    Since I can't seen any way from within SAP to change the fields returned by this report, I thought I'd have a stab at writing my own SQL to select out the same data along with the extra fields I wanted.  That's when the problems began...try as I might, I cannot get my figures to tally with the SAP Report.
    They are almost correct, but not quite. I am sure that I am missing a selection or some other element of the logic that B1 uses to create the built in report.
    If you want, I can post the SQL I'm using....I'm not an SQL guru by any means, but I do know my way around it; the biggest problem I have is that I cannot find any documentation as to the 4 letter tables that SAP uses and their relationships except on the most basic level (e.g ORIN is Open Return Invoice [maybe])
    Then I thought maybe it might be possible to edit that report section in B1 using the SDK.  That would be a better solution as I would not have to 'reinvent the wheel', I can just SELECT an extra field or three to include in the report.
    So my question is
    ->Does anyone have a stored procedure for SQL Server that can replicate correctly the SAP B1 "Customer Receivable Aging", even just the process SAP uses to gather this data would be good.
    OR
    is it possible to edit this report in SAP to put in the extra fields I want.
    Or, am I totally barking up the wrong tree? Thanks in advance, I know this is a long post.

    Hi Stephen,
    There should be a print layout attached to the on-screen report. This can be altered to show the additional fields you want without resorting to SDK or SQL development.
    When you have the Customer Receivables Ageing report open on screen, choose Tools-Print Layout Designer or click on the Print Layout Designer icon on the toolbar. When prompted, choose the layout you wish to edit and you'll be taken to the layout design. In the layout, you can add additional fields and should be able to add most business partner fields. As the report is set to portrait by default, I recommend changing it to landscape so you have lots more space to add the extra fields you want. This report writer is fairly intuitive, if a little basic.
    You will need to save this new report design, set it to be the default layout and then when you select to print the Customer Receivables Ageing report (ie Print Preview or Print) you will see the new report.
    Hope this helps,
    Owen

  • Is this a BUG???  Database Export not including Foreign Key Constraints

    I'm using SQL Developer 1.5.4 with both the 59.47 and 59.59 patches installed. I want to do a database export from a 10g XE schema, and include all objects in the resulting DDL. So, I select ALL the checkboxes in the export wizard and when I get to Step 3 to specify objects, I don't see any of my constraints in the listbox... no foreign key constraints, no primary key constraints, no check constraints, nothing. Is this a bug, or is there a workaround, or what could I possibly be doing wrong? We want to be able to use the database export feature to easily transport and track modifications to our entire schema using source control compare.
    Any help or alternate suggestions would be apprieciated.
    Thanks,
    Matt

    Thanks skutz, we just figured that out this morning. Also, it should be noted that you need to be logged in as the owner of the schema otherwise selecting nothing in the filter will give you nothing, but selecting items in the filter will give you those items even if you're not connected as the schema owner. I wonder if that is the detail of the Bug 8679318.
    Edited by: mattsnyder on Jul 14, 2009 9:24 AM

  • Stored Procedure for Crystal Reports

    Hi All,
    I developed this test stored procedure to see wheather we could a stored procedure for crystal reports. It compiled without any problem, but when I run it, it gives me error message. Here is the stored Procedure..
    CREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(
    TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
    TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
    AS
    BEGIN
    OPEN TEST_CURSOR FOR
    SELECT *
    FROM TEST_TABLE
    WHERE TEST_TABLE.ID = TEST_PARAMETER;
    END TEST_PROCEDURE;
    And
    This is the error message..
    ERROR at line 2:
    ORA-06550: line 2, column 1:
    PLS-00201: identifier 'TEST_PROC' must be declared
    ORA-06550: line 2, column 1:
    PL/SQL: Statement ignored
    I have created the package sucessfully.
    I was wondering If any one of you can advice me where I am making the mistake.
    Thank you

    CREATE OR REPLACE PROCEDURE WOLD1SIM.TEST_PROCEDURE(TEST_CURSOR IN OUT TEST_PACKAGE.TEST_TYPE,
                                                         TEST_PARAMETER IN TEST_TABLE.ID%TYPE)
    ...you have 2 parameters in your procedure WOLD1SIM.TEST_PROCEDURE(). you should also use two parameters when you execute the procedure.

  • Stored Procedure for Batch Number Format and Block Duplicate Batch Number

    Hi Experts !
    I am new one in forum asking question.. I want Stored procedure for Batch Number Format. I want fix one Batch number format in Stored Procedure.
    Example :
    My Batch number format Like  BATCH00001 - It should be first five digit is text format and next five is Numeric.
    IF create Goods receipt PO or Goods receipt stage I create batch number like BATCH 00001 or any other number means don't add that document and also duplicated batch number also does not allowed. please give me the solutions. I am sorry for my bad english .

    Dear Nagarajan K.
                         Thanks for your replay ..
    IF @transaction_type IN ('A','U') AND (@object_type = '106' )
    BEGIN
    set @item = LEFT( @list_of_cols_val_tab_del, CHARINDEX(CHAR(9),  @list_of_cols_val_tab_del,1) - 1)
    set @batch = substring(@list_of_cols_val_tab_del, len(@item)+1, (CHARINDEX(CHAR(9),  @list_of_cols_val_tab_del,len(@item)+2)) - (len(@item)+1))
    --set @base =( select basetype from ibt1 where batchnum = ltrim(rtrim(replace(@batch,char(9),''))))
    set @count = (select count(*) from oibt quantity > 0 and where  batchnum = ltrim(rtrim(replace(@batch,char(9),''))))
    if @count > 1
    begin
    set @error = 1
    set @error_message = 'Please enter different Batch Code for batch ''' + @batch + ''' for item ' + @item 
    select @error, @error_message
    END
    END
                  I used above Stored Procedure. here we can use one batch number for different item but  i want to block one batch we should use one item and one time only after than we never use that batch number for same item and another item.
             After that I want format for Batch, we should follow unique Batch number for all items.

  • Stored procedure for getting host name, host instance and status of that host is it running or stopped.

    Hello all,
    yesterday I got one task in that I have to stored procedure for getting host name, host instance and status of that host is it running or stopped.
    any body knows where exactly, In which table this details are there in BizTalk databases.
    thanks

    Status of the host instance is not stored in the SQL database for you to query the status using stored procedure. You have to either use Powershell or WMI to get the status.
    In SQL, following table contains the details about the host like Name, LoginName, IsDisables etc but status of the host instance is not stored in the database.
    SELECT * FROM BizTalkMgmtDb..adm_HostInstance
    Powershell to get the status:
    http://axonolympus.nl/?page_id=186&post_id=969&cat_id=6&lang=en
    WMI to get the status:
    https://msdn.microsoft.com/en-us/library/aa561820.aspx?f=255&MSPPError=-2147217396
    https://msdn.microsoft.com/en-us/library/aa578621.aspx
    Regards,
    M.R.Ashwin Prabhu
    If this answers your question please mark it accordingly. If this post is helpful, please vote as helpful by clicking the upward arrow mark next to my reply.

  • Stored Procedure for lead code to be entered in sales order

    Hi All,
    I was trying to work on stored procedure for lead code not to be allowed to enter in sales order.
    It is system behaviour that it is allowing to take even lead code in sales order and add the transaction but my customer wants to block if any one of you could help me out to develop stored procedure.
    Thanks & regards-
    Monika

    Hi Monika,
    Try:
    If @object_type='17' and @transaction_type IN ('A','U')
    BEGIN
    If Exists (Select T0.DocEntry from ORDR
    Where T0.CardCode IN (SELECT CardCode FROM OCRD WHERE CardType = 'L')
    And T0.DocEntry = @list_of_cols_val_tab_del)
    Begin
    Select @error = 17, @error_message = 'Lead is not allowed for Sales Order'
    End
    END
    Thanks,
    Gordon

  • Stored Procedure for Zero Price in GRPO

    Hi all,
       Can anybody let me know the required stored procedure for restricting zero price in the GRPO transaction .
    Thanks in advance ,
    Aditya

    Use this in your SBO_SP_TransactionNotification
    IF @transaction_type = 'A' AND @object_type = '20'
    BEGIN
    IF EXISTS (SELECT T0.ItemCode FROM [dbo\].[PDN1\] T0
    WHERE (T0.Price = 0 OR T0.Price IS NULL) AND T0.DocEntry = @list_of_cols_val_tab_del
    BEGIN
    SELECT @Error = 1, @error_message = 'Item without Price'
    END
    END
    Suda

Maybe you are looking for

  • Filter expression producing different results after upgrade to 11.1.1.7

    Hello, We recently did an upgrade and noticed that on a number of reports where we're using the FILTER expression that the numbers are very inflated. Where we are not using the FILTER expression the numbers are as expected. In the example below we ra

  • SL and Boot Camp - new installation

    Just purchased another mac book pro and upgraded to snow leopard. Need to install a windows vista and MS office using boot camp. Need advice - what size partition should I give to the windows partition? System HD is 250 GB. This is a complete office

  • I'm a bit confused about this 32 bit and 64 bit stuff

    Martin Evening's book says "If your computer hardware is 64 bit enabled and you are running a 64 bit operating system, you can run Lightroom as a 64 bit program." Well I'm currently running XP 64 Bit with 4 GB of RAM inside. How do I run Lightroom in

  • Script to pdf

    i needed a help in converting a script to pdf file , i know there is one standard programto do so. but im unable toget the program name. please let me know if any body knows. thanx.

  • RFC Sender Asynchronous -- File Problem

    Hi all, I want to sent an asynchronous RFC to a file but when I execute my scenario in R3 it always returns a dump. In the XI monitoring I get the response error from the file: "Unable to read the payload from the message object". I think its strange