Composite Foreign Key

Dear All
please correct this syntax for composite foreign key.
Ater Table emp_pays
Add Constraints emp_pt_fk Foreign Key(emp_id,pt_id) Referenes emp(emp_id),pay_type(pt_id);
Thanks in advances
Regards,

No, You cant get a composite keys based on two different primary keys. Reason for this can be like unique index is being used when we create any primary key. When we create a composite primary key, one index is created for the two fields and thus one index store the values for two columns involved in the composite primary key and these values are stored in pairs. So when any foreign key references this composite primary key, it will match the data in pairs as it is stored in the index(unique index).
Now when we say to create a composite foreign key based on two different primary keys , we are taking into account two indexes for two different fields. So there is no pairing in these two indexes. So when we will create foreign key using this, it will not get a pair of values or we can say oracle cant get us consistent pair of values from two indexes. So maintaining integrity will not be possible.
Yes you can create two foreign keys on one column which can refer two different primary keys.
Regards

Similar Messages

  • Composite Foreign Keys

    How do I map a composite foreign key using toplink?
    I can reference a particular record in mytable using the following sql statement:
    SELECT * FROM mytable m WHERE m.foreign_id = x AND m.type = y;
    Where x represents the primary key in my entity and y represents a second part of the primary key (e.g. "type 1")
    How do I accomplish this from within my entity?
    Thanks

    If you are using JPA, you need to use either an IdClass or EmbeddedId for composite primary keys.
    If you are using the TopLink native API you just need to call addPrimaryKeyFieldName() with both column names.
    See,
    http://en.wikibooks.org/wiki/Java_Persistence/Identity_and_Sequencing#Composite_Primary_Keys
    James : http://www.eclipselink.org

  • Optional Composite Foreign Key

    The tool doesn't seem to be handling this correctly when some of the columns are mandatory and others are nullable. I have a composite foreign key where one column is part of the primary key and the other is not. In the Columns properties of the Table dialog, it shows the column that is part of the primary key as mandatory. But on the diagram, the "red dot" indicator is missing. It also give me an error on the Foreign Keys properties when I click OK or Apply.

    No, You cant get a composite keys based on two different primary keys. Reason for this can be like unique index is being used when we create any primary key. When we create a composite primary key, one index is created for the two fields and thus one index store the values for two columns involved in the composite primary key and these values are stored in pairs. So when any foreign key references this composite primary key, it will match the data in pairs as it is stored in the index(unique index).
    Now when we say to create a composite foreign key based on two different primary keys , we are taking into account two indexes for two different fields. So there is no pairing in these two indexes. So when we will create foreign key using this, it will not get a pair of values or we can say oracle cant get us consistent pair of values from two indexes. So maintaining integrity will not be possible.
    Yes you can create two foreign keys on one column which can refer two different primary keys.
    Regards

  • Composite Foreign Key Relationships

    I'm having problems defining relationships that are using the same set of fields in a composite primary key and a composite foreign key. Are there any examples for doing this kind of thing. I think I have the primary keys set up correctly but the foreign key defs aren't working yet. From the spec it looks ike it should be something like this:
    @ManyToOne
         @PrimaryKeyJoinColumns({
         @PrimaryKeyJoinColumn(name="CGMTI_ID"),
         @PrimaryKeyJoinColumn(name="MISSION_REF_DATE")})
         CgmtiHeader cgmtiHeader;
    Also, the composite foreign keys seem to make Dali's entity generation blow up.

    This mapping is missing the referencedcolumn definition, and because it is a composite pk, it cannot figure out a default value. So it should similar to:
    @ManyToOne
    @PrimaryKeyJoinColumns({
    @PrimaryKeyJoinColumn(name="CGMTI_ID", referencedColumnName="CGMTI_ID),
    @PrimaryKeyJoinColumn(name="MISSION_REF_DATE", referencedColumnName="MISSION_REF_DATE)})
    CgmtiHeader cgmtiHeader;
    Similar discussions exist in threads:
    Extra Columns in ManyToMany table workaround
    and
    http://forums.java.net/jive/thread.jspa?threadID=2564&messageID=36441
    both of which list blogs showing examples.
    Best Regards,
    Chris

  • Composite foreign key, LOV, WSG, Designer 6i

    Hello,
    I have one composite foreign key that consists of 3 columns,
    which belongs to three different tables (there are
    master-detal-detail relationships between those 3 tables). Let's
    call those tables A, B and C.
    Now, I'd like to generate wsg module (based on table D) that has
    all three columns displayed. Also, I'd like to generate three
    dependant LOVs in such way that I am able first to select row
    from table A using first LOV. Second LOV should display rows from
    table B, but only those rows that are in context of A. Similary,
    third LOV should display rows from table C, but only rows in
    context of B.
    Is there any way to this in Designer 6i Release 4 ? This way
    default behaviour in Designer 2.1.2 and 6.
    Thanks.
    Goran Oparnica
    IN2 d.o.o.
    Zagreb

    The Headstart Utilities are part of the Headstart Oracle Designer package which is downloadable from OTN. Headstart Oracle Designer is an accelerator suite consisting of Templates, Object Libraries, Preference Sets, PL/SQL libraries and utilities to make using Designer to generate Forms applications easier.
    To get more information on Headstart you can go to the OTN home page, choose Internet Tool under the Products section on the menu. Under the Headstart 'Internet Developer Suite', click on Headstart Oracle Designer
    Regards,
    Lauri

  • Need help with defining composite foreign keys

    Hi there, i´m in troubles with defining a composite foreign key. The scenario is:
    * Table TABLE_A has no unique primary key. Instead its primary key is a composition of five foreign keys.
    * Table TABLE_B and TABLE_A have a many-to-many relationship with each other.
    When I create the entity manager for running the DDL scripts into the DB i´m getting "ORA-02270: no matching unique or primary key for this column-list".
    These are my entities (sorry the portuguese terms, but i think the issue can be understood without translation...).
    @Entity
    @Table( name = "DESTAQUE_PDE" )
    public class DestaquePDE implements Serializable {
         private static final long serialVersionUID = 4694859522628884981L;
         @Id
         @GeneratedValue( strategy = GenerationType.SEQUENCE )
         @Column( name = "ID_DESTAQUE_PDE", nullable = false )
         private long id;
    //Some fields were ommited here for simplicity....
         @ManyToMany( cascade = CascadeType.ALL )
         @JoinTable( name = "JOIN_DESTAQUES_CORRELACAO",
                        joinColumns           = @JoinColumn( name = "JOIN_ID_DESTAQUE", referencedColumnName = "ID_DESTAQUE_PDE" ),
                        inverseJoinColumns      = {@JoinColumn( name = "JOIN_ID_COR_PUB_ALVO", referencedColumnName = "FK_ID_PUBLICO_ALVO" ),
                                                 @JoinColumn( name = "JOIN_ID_COR_RES_LINHA", referencedColumnName = "FK_ID_RESOLUCAO_LINHA" ),
                                                 @JoinColumn( name = "JOIN_ID_MOD_CRED", referencedColumnName = "FK_ID_MODALIDADE_CREDITO" ),
                                                 @JoinColumn( name = "JOIN_ID_AG_FIN", referencedColumnName = "FK_ID_AGENTE_FINANCEIRO" ),
                                                 @JoinColumn( name = "JOIN_ID_PROG_LINHA", referencedColumnName = "FK_ID_PROGRAMA_LINHA" )}
         private List<EntradaTabelaCorrelacao> correlacoes;
    @Entity
    @Table( name = "CORRELACAO" )
    @IdClass( TabelaCorrelacaoPK.class )
    public class EntradaTabelaCorrelacao implements Serializable {
         private static final long serialVersionUID = -3337072470212918325L;
         @Id
         @Column( name = "FK_ID_PUBLICO_ALVO" )
         private long idPublicoAlvo;
         @Id
         @Column( name = "FK_ID_RESOLUCAO_LINHA" )
         private long idResolucaoLinha;
         @Id
         @Column( name = "FK_ID_MODALIDADE_CREDITO" )
         private long idModalidadeCredito;
         @Id
         @Column( name = "FK_ID_AGENTE_FINANCEIRO" )
         private long idAgenteFinanceiro;
         @Id
         @Column( name = "FK_ID_PROGRAMA_LINHA" )
         private long idProgramaLinha;
         @Column( name = "CS_SITUACAO", nullable = false, length = 1 )
         private String situacao;
         @ManyToMany( mappedBy = "correlacoes" )
         private List<DestaquePDE> destaquesPDE;
    //more relationships ommited for simplicity....
    public class TabelaCorrelacaoPK implements Serializable {
         private long idPublicoAlvo;
         private long idResolucaoLinha;
         private long idModalidadeCredito;
         private long idAgenteFinanceiro;
         private long idProgramaLinha;
    //getters and setters ommited....
    These are part of the DDLs generated by toplink:
    CREATE TABLE DESTAQUE_PDE (
         ID_DESTAQUE_PDE NUMBER(19) NOT NULL,
         VL_ALOCACAO_AUTORIZADA NUMBER(16,2) NOT NULL,
         VL_TOTAL NUMBER(16,2) NOT NULL,
         QT_OPERACOES NUMBER(16,2) NOT NULL,
         NM_DESTAQUE_PDE VARCHAR2(255) NOT NULL,
         VL_ESTIMATIVA_REAPLICACAO NUMBER(16,2) NOT NULL,
         VL_MONTANTE NUMBER(16,2) NOT NULL,
         FK_ID_PDE NUMBER(19) NOT NULL,
         FK_RESOLUCAO_PROGRAMA NUMBER(19) NOT NULL,
         PRIMARY KEY (ID_DESTAQUE_PDE)
    CREATE TABLE CORRELACAO (
         FK_ID_PUBLICO_ALVO NUMBER(19) NOT NULL,
         FK_ID_RESOLUCAO_LINHA NUMBER(19) NOT NULL,
         FK_ID_MODALIDADE_CREDITO NUMBER(19) NOT NULL,
         FK_ID_AGENTE_FINANCEIRO NUMBER(19) NOT NULL,
         FK_ID_PROGRAMA_LINHA NUMBER(19) NOT NULL,
         CS_SITUACAO VARCHAR2(1) NOT NULL,
         PRIMARY KEY (FK_ID_PUBLICO_ALVO, FK_ID_RESOLUCAO_LINHA, FK_ID_MODALIDADE_CREDITO, FK_ID_AGENTE_FINANCEIRO, FK_ID_PROGRAMA_LINHA)
    ALTER TABLE DESTAQUE_PDE
    ADD CONSTRAINT FK_DESTAQUE_PDE_FK_ID_PDE
    FOREIGN KEY (FK_ID_PDE)
    REFERENCES PDE (ID_PDE)
    ALTER TABLE DESTAQUE_PDE
    ADD CONSTRAINT DESTAQUEPDEFKRESOLUCAOPROGRAMA
    FOREIGN KEY (FK_RESOLUCAO_PROGRAMA)
    REFERENCES RESOLUCAO_PROGRAMA (ID_RESOLUCAO_PROGRAMA)
    (*) ALTER TABLE CORRELACAO
    ADD CONSTRAINT CORRELACAO_FK_ID_PUBLICO_ALVO
    FOREIGN KEY (FK_ID_PUBLICO_ALVO)
    REFERENCES PUBLICO_ALVO (ID_PUBLICO_ALVO)
    ALTER TABLE CORRELACAO
    ADD CONSTRAINT CORRELACAOFKID_RESOLUCAO_LINHA
    FOREIGN KEY (FK_ID_RESOLUCAO_LINHA)
    REFERENCES RESOLUCAO_LINHA (ID_RESOLUCAO_LINHA)
    ALTER TABLE CORRELACAO
    ADD CONSTRAINT CRRELACAOFKIDMODALIDADECREDITO
    FOREIGN KEY (FK_ID_MODALIDADE_CREDITO)
    REFERENCES MODALIDADE_CREDITO (ID_MODALIDADE_CREDITO)
    ALTER TABLE CORRELACAO
    ADD CONSTRAINT CORRELACAOFKIDAGENTEFINANCEIRO
    FOREIGN KEY (FK_ID_AGENTE_FINANCEIRO)
    REFERENCES AGENTE_FINANCEIRO (ID_AGENTE_FINANCEIRO)
    ALTER TABLE CORRELACAO
    ADD CONSTRAINT CORRELACAOFK_ID_PROGRAMA_LINHA
    FOREIGN KEY (FK_ID_PROGRAMA_LINHA)
    REFERENCES PROGRAMA_LINHA (ID_PROGRAMA_LINHA)
    As I told before, the error i´m getting with these mappings is:
    ORA-02270: no matching unique or primary key for this column-list
    The error occurs exactly when executing the instruction with (*).
    Thanks in advance for any help!
    Regards
    Loreno

    The error says that the table PUBLICO_ALVO does not have a primary key or unique constraint for (ID_PUBLICO_ALVO), so you cannot define a foreign key constraint to it. This table was not included in your DDL, how was it created? You need to add a primary key or unique constraint in this table on this field.
    If you do not wish to have the unique or foreign key defined you can just ignore the error, it is just a warning.
    <p>---
    <br>James Sutherland
    <br>Oracle TopLink, EclipseLink
    <br>Wiki: Java Persistence, EclipseLink

  • Composite foreign key issue

    Hi,
    I am trying to create a composite foriegn key. I have created my primary key as a composite key, made up of three fields.
    Table 1
    PatientID - Made from 3 fields(a,b,c)(primry key)
    Table B
    PatiendID- (should be the foreign key which references table1)
    However i am finding that when i try to create my constraint i get the following messages
    error 02270 - no matching unique or primarty key for this column list.
    below is the sample code i am using to create my foreign key)
    (ALTER TABLE XD_PatientSedation ADD CONSTRAINT fk_Sedation_PatientID FOREIGN KEY (PatientID)REFERENCES XD_Patient_Demographics(PatientID)
    I am really stuck on this and dont quite know what to do.
    Hope you can help.
    Thanks
    Jagdish

    Just speaking about design, when you want to use a foreign key, it already means that the referenced columns represent something important enough to be a primary key of some other table. I don't understand the business logic of your example (using real table and column names would help), but the solution is probably one of these two :
    a) your foreign key should in fact refer to (a,b,c), the complete primary key of the first table (what was suggested by the others).
    b) your foreign key should stay as 'a' (patientid?), you should have a third table (patients?) whose primary key is 'a', and your "Table 1" should have a foreign key on 'a', referencing the third table. In this case you may find it silly to create a new table with only one column, but I would bet that you will very soon think of interesting attributes which could be added to this table.
    In any case, I think that Oracle did a good job by forcing an improvement of your design !

  • Primary key foreign key dependencies

    hi gems...
    I have a table with composite primary key (COL1, COL2)..
    create table TABLE1 (COL1, COL2);
    alter table TABLE1 add constraint PK_TABLE1 primary key (COL1, COL2);
    Now i am trying to make another table which will refer to the COL1 of the first table.
    create table TABLE2 (COL3, COL4);
    alter table TABLE2 add constarint FK_TABLE2 (COL3) references TABLE1(COL1);
    but it is failing with "no matching unique or primary key" error.

    You have created a composite primary key, so there must be composite foreign key that references the composite primary key. You cannot create Foreign key that references to single column of the composite primary key.

  • Does a foreign key have to be a primary key

    Hey all.I was checking on the database code written by sambapos.To my surprise, I found a foreign key that is not a primary key anywhere.
    Is that possible?
    If, so why?
    I am really astonished.

    Limitations and Restrictions
    A foreign key constraint does not have to be linked only to a primary key constraint in another table; it can also be defined to reference the columns of a UNIQUE constraint in another table.
    When a value other than NULL is entered into the column of a FOREIGN KEY constraint, the value must exist in the referenced column; otherwise, a foreign key violation error message is returned. To make sure that all values of a composite foreign key constraint
    are verified, specify NOT NULL on all the participating columns.
    FOREIGN KEY constraints can reference only tables within the same database on the same server. Cross-database referential integrity must be implemented through triggers. For more information, see
    CREATE TRIGGER (Transact-SQL).
    FOREIGN KEY constraints can reference another column in the same table. This is referred to as a self-reference.
    A FOREIGN KEY constraint specified at the column level can list only one reference column. This column must have the same data type as the column on which the constraint is defined.
    A FOREIGN KEY constraint specified at the table level must have the same number of reference columns as the number of columns in the constraint column list. The data type of each reference column must also be the same as the corresponding column in the column
    list.
    The Database Engine does not have a predefined limit on either the number of FOREIGN KEY constraints a table can contain that reference other tables, or the number of FOREIGN KEY constraints that are owned by other tables that reference a specific table.
    Nevertheless, the actual number of FOREIGN KEY constraints that can be used is limited by the hardware configuration and by the design of the database and application. We recommend that a table contain no more than 253 FOREIGN KEY constraints, and that it
    be referenced by no more than 253 FOREIGN KEY constraints.
    FOREIGN KEY constraints are not enforced on temporary tables.
    If a foreign key is defined on a CLR user-defined type column, the implementation of the type must support binary ordering. For more information, see
    CLR User-Defined Types.
    A column of type varchar(max) can participate in a FOREIGN KEY constraint only if the primary key it references is also defined as type
    varchar(max).
    Read this article
    http://msdn.microsoft.com/en-us/library/ms189049.aspx
    Regards, Ashwin Menon My Blog - http:\\sqllearnings.com

  • Foreign key constraint on multi-column primary key accepts 1 empty column!?

    Hi, we have a reference table with a two-column primary key. In the child table there is a non-mandatory foreign key constraint to this table. So if both child columns are null it's ok too. But now we see that if one of the two child table columns that build up the foreign key is null, the other column can have any (non-existant in the master-tabel) value you like!? That does not make sense.
    Can anyone explain this to me???
    Regards, Paul.

    Paul, I believe that this is in accordance to the ANSI SQL standard requirement for the treatment of nulls in a multi-column FK. In any case Oracle specifically states this is the way FK work From the 10 Concepts manual, Ch 21 Data Integrity, topic Nulls and Foreign Keys:
    The relational model permits the value of foreign keys either to match the referenced primary or unique key value, or be null. If any column of a composite foreign key is null, then the non-null portions of the key do not have to match any corresponding portion of a parent key. <<HTH -- Mark D Powell --

  • Composite primary key as foreign key not working

    i want have two tables
    in one table i make a composite primary key
    and in the other table i refer one of the column of the composite key from the above table as foreign key in this table but this didn't work.
    eg:
    create table temp1
    ( name char2(10),
    ssn# number(10)
    address varchar2(10)
    constraint (cons_1)primary key(name,ssn#) );
    create table temp2
    ( name1 char2(10) references temp1(name),
    add varchar(20));
    this didn't work....can't create temp2 table it's giving error

    The following includes some corrections and some suggestions. Your original code had several problems: missing comma, invalid name, invalid data type, no unique key for the foreign key to reference. The following fixes all of those and adds some meaningful names for the constraints and formats it so that it is easier to read.
    CREATE TABLE temp1
      (name       VARCHAR2 (10),
       ssn#       NUMBER   (10),
       address    VARCHAR2 (10),
       CONSTRAINT temp1_name_ssn#_pk
                  PRIMARY KEY (name, ssn#),
       CONSTRAINT temp1_name_uk
                  UNIQUE (name))
    Table created.
    CREATE TABLE temp2
      (name1      VARCHAR2 (10),
       address    VARCHAR2 (20),
       CONSTRAINT temp2_name1_fk
                  FOREIGN KEY (name1)
                  REFERENCES temp1 (name))
    Table created.

  • Is it possible to create foreign key from composite key in other table.

    SQL> desc PRODUCT_CONFIG_OPTION;
    Name Null? Type
    CONFIG_ITEM_ID NOT NULL VARCHAR2(20) --composite primary key
    CONFIG_OPTION_ID NOT NULL VARCHAR2(20) --composite primary key
    CONFIG_OPTION_NAME VARCHAR2(100)
    DESCRIPTION VARCHAR2(255)
    SEQUENCE_NUM NUMBER(18)
    LAST_UPDATED_STAMP TIMESTAMP(6)
    LAST_UPDATED_TX_STAMP TIMESTAMP(6)
    CREATED_STAMP TIMESTAMP(6)
    CREATED_TX_STAMP TIMESTAMP(6)
    SQL> DESC PRODUCT_CONFIG_ITEM;
    Name Null? Type
    CONFIG_ITEM_ID NOT NULL VARCHAR2(20)
    CONFIG_ITEM_TYPE_ID VARCHAR2(20)
    CONFIG_ITEM_NAME VARCHAR2(100)
    DESCRIPTION VARCHAR2(255)
    LONG_DESCRIPTION CLOB
    IMAGE_URL VARCHAR2(255)
    LAST_UPDATED_STAMP TIMESTAMP(6)
    LAST_UPDATED_TX_STAMP TIMESTAMP(6)
    CREATED_STAMP TIMESTAMP(6)
    CREATED_TX_STAMP TIMESTAMP(6)
    SQL> desc product;
    Name Null? Type
    PRODUCT_ID NOT NULL VARCHAR2(20)
    PRODUCT_TYPE_ID VARCHAR2(20)
    PRIMARY_PRODUCT_CATEGORY_ID VARCHAR2(20)
    MANUFACTURER_PARTY_ID VARCHAR2(20)
    FACILITY_ID VARCHAR2(20)
    INTRODUCTION_DATE TIMESTAMP(6)
    SUPPORT_DISCONTINUATION_DATE TIMESTAMP(6)
    SALES_DISCONTINUATION_DATE TIMESTAMP(6)
    SALES_DISC_WHEN_NOT_AVAIL CHAR(1)
    INTERNAL_NAME VARCHAR2(255)
    BRAND_NAME VARCHAR2(100)
    COMMENTS VARCHAR2(255)
    =========
    CREATE TABLE PROD_CONFIG_PROD_CONFIG_OPTION (
    PRODUCT_ID VARCHAR2(20),
    CONFIG_ITEM_ID VARCHAR2(20),
    CONFIG_OPTION_ID VARCHAR2(20),
    PAGE_NUM_TO NUMBER(18),
    ALTERNATE_PAGE_NUM_TO1 NUMBER(18),
    ALTERNATE_PAGE_NUM_TO2 NUMBER(18),
    ALTERNATE_PAGE_NUM_TO3 NUMBER(18),
    LAST_UPDATED_STAMP TIMESTAMP(6),
    LAST_UPDATED_TX_STAMP TIMESTAMP(6),
    CREATED_STAMP TIMESTAMP(6),
    CREATED_TX_STAMP TIMESTAMP(6),
    CONSTRAINT PK_PROD_CAT_CONFIG_MOD PRIMARY KEY (PRODUCT_ID),
    CONSTRAINT FK_PRODUCT_ID FOREIGN KEY (PRODUCT_ID) REFERENCES PRODUCT(PRODUCT_ID),
    CONSTRAINT FK_CONFIG_ITEM_ID FOREIGN KEY (CONFIG_ITEM_ID) REFERENCES PRODUCT_CONFIG_ITEM(CONFIG_ITEM_ID),
    CONSTRAINT FK_CONFIG_OPTION_ID FOREIGN KEY (CONFIG_OPTION_ID) REFERENCES PRODUCT_CONFIG_OPTION(CONFIG_OPTION_ID) )
    TABLESPACE DATA_SMALL
    i try to create this table if i omit 3rd foreign key constraint then table successfully created.but including trd foreign key constraint it return error "ORA-02270: no matching unique or primary key for this column-list"
    i checked everything is it possible to create foreign key from composite key in other table.

    And
    CONSTRAINT FK_CONFIG_OPTION_ID FOREIGN KEY (CONFIG_ITEM_ID,CONFIG_OPTION_ID) REFERENCES PRODUCT_CONFIG_OPTION(CONFIG_ITEM_ID,CONFIG_OPTION_ID)
    ?

  • Adding a foreign key based on composite key of other table

    Hi All,
    I have two tables one named 'products' (T1) and other 'codes' (T2). The product_code column in T1 needs to reference code_id values where code_type="STREET" from T2. T2 primary key is based on two columns 'code_id' and 'code_type'.
    The issue is t1 table has only one of the column from T2. i.e; product_code (T1) corresponds to code_id (T2) and code_type should always have value "STREET"
    I am not getting how to implement the foreign key constraint on T1 in such scenario. Hope my explanation is clear. Feel free to ask for more clarifications. Please suggest.
    Thanks
    Edited by: user5108636 on 26/09/2011 21:20

    user5108636 wrote:
    Hi All,
    I have two tables one named 'products' (T1) and other 'codes' (T2). The product_code column in T1 needs to reference code_id values where code_type="STREET" from T2. T2 primary key is based on two columns 'code_id' and 'code_type'.
    The issue is t1 table has only one of the column from T2. i.e; product_code (T1) corresponds to code_id (T2) and code_type should always have value "STREET"
    I am not getting how to implement the foreign key constraint on T1 in such scenario. Hope my explanation is clear. Feel free to ask for more clarifications. Please suggest.post CREATE TABLE statement for PRODUCTS & CODES tables

  • In ADF how can i insert data in multiple table if they have foreign key

    I have started working on ADF and can anybody inform me in ADF how can i insert data in multiple table if they have foreign key,please?
    Thnak you very much.

    Hello,
    Still no luck.I am surely doing silly mistakes.Anyway,Here are my workings-
    1> student_mst (id(pk),studentname) and student_guard_mst(id(fk),guardianname)
    2> created EO from both of the tables,made id in both EO as DBSequence and an association was also generated.
    3> i made that association composite by clicking the checkbox
    4> i created 2 VO from 2 EO.
    5> put those VO in Application Module.
    6> dragged and dropped 2 VO on my jspx page and dropped them as ADF Form.
    Now what to do please?

  • FOREIGN KEY IS PRIMARY KEY

    Hi,
    Has anyone come across the following problem?
    I have two tables
    customer individual
    customer_id (PK) customer_id (PK)
    customer_id in individual is the primary key for that table. It is also a foreign key ( related back to customer).
    If I use JDeveloper to drag in the two tables ( into a class diagraqm), I have a problem.
    JDeveloper "sees" the Individual bean foreign key mapping and generates a getCustomer() method (which returns a handle to the appropriate customer bean).
    However as it "removes" the getCustomer_id() method(which returns the actual customer_id), the primary_key reference is dropped.
    When I try and compile, JDeveloper quite rightly complains with "where is the primary key".
    Can anyone help? Do I need to make it a rule that the foreign key is not also the primary key?
    thanks in advance,
    Kevin

    Hello,
    I am having the same problem attempting to use a foreign key as a primary key in an EJB 2.0 CMR running on WLS 6.1. If I do not set the foreign key portion of my composite key in the ejbCreate() method I get an error stating that the field cannot be null (and must be set), when I set the field in the ejbCreate I then get an Error in the ejbPostCreate stating that CMR fields cannot be set using the setXXX methods. The entity relations are as follows:
    SalesOrder <--------------------------------------->SalesOrderProduct
    SalesOrder = (orderid(PK)+orderstatus+salesrepid+contractdate+processdate)
    SalesOrderProduct = (orderid(PK/FK)+productid(PK)+qty+unitcost)
    The CMR relationship is bi-directional. The SalesOrder entity bean's ejbPostCreate() method
    invokes a helper method that attempts to create the salesOrder product entity as part of the salesorder create transaction and that's when I get the errors stated above.
    Have or anyone found out how to handle this kind of cmr using the Weblogic server (6.1) and ejb 2.0??
    Thanks,
    Darryl

Maybe you are looking for

  • Solution and Service level Reporting in Solution Manager

    Hi All, I have got some requirement , can anyone please provide me the link/blog regarding Solution and Service level Reporting. Thanks, vk

  • CommandLink doesn't work with rendered-attribute

    Hello, I have quite a strange problem. I have a commanLink, which has a rendered attribute. The link is rendered conditionally, so the rendered-value comes from a bean. <h:commandLink rendered="#{Bean.canEdit}" action="#{Bean.selectDocumentToEdit}" >

  • What settings do i use with Entourage

    i had a mobile me account....i migrated to iCloud.  i still use my email address with @mac.com.  iCloud works on my iphone and i get the email pushed to my iphone.  however, i now get server time outs from my computers when accessing the emails.  i s

  • Menu background color has changed after applying Forms Patch3 (10.1.2.3.0)

    Hi, we have applied Patch3 on our Forms Environment. Now the menu background color has changed from green to gray (colorScheme is "teal" in formsweb.cfg). This behavior isn't documented and our customer want's to get the green menubar back... Any hin

  • Upload files in form

    Hey I have a form that uploads a file.  I am having trouble with some of the code and hoping someone can help.  FORM FIELD <tr>                           <td><strong>Upload Submission</strong></td>                     <td><input