COMPOSITE PRIMARY KEY

Hi all

I need mapping composite primary key to foreign key.

Example:

first create LOCATION_MASTER table with composite primary key,

CREATE TABLE LOCATION_MASTER (LOC_CITYCODE VARCHAR2 (10))
LOC_CITY VARCHAR2 (30),
CONSTRAINT ANN_LOCMAS_PK PRIMARY KEY (LOC_CITYCODE, LOC_CITY)
);

Then create the route_master table. In the table route_master source_city, destination_city maps to loc_city

CREATE TABLE ROUTE_MASTER (ROUTE_ID NUMBER (3),)
SOURCE_CITY VARCHAR2 (30),
DESTINATION_CITY VARCHAR2 (30),
CONSTRAINT ANN_INPK PRIMARY KEY (ROUTE_ID).
CONSTRAINT ANN_INFK FOREIGN KEY (SOURCE_CITY, DESTINATION_CITY)
REFERENCES LOCATION_MASTER (LOC_CITY)
);

If I create like that, then I got error...

The samething is my need. So please fix the code that I have attached.

Please do what is necessary...



Thank you
Ann

CONSTRAINT ANN_LOCMAS_PK PRIMARY KEY (LOC_CITYCODE, LOC_CITY)

CONSTRAINT ANN_INFK FOREIGN KEY (SOURCE_CITY, DESTINATION_CITY)
REFERENCES LOCATION_MASTER (LOC_CITY)

It is not possible to refer to the part of the parent key. In your case, you must create a separate unique constraint on LOCATION_MASTER. LOC_CITY and then to establish referential constraints of ROUTE_MASTER. SOURCE_CITY and ROUTE_MASTER. DESTINATION_CITY individually i.e. two different referential constraints.

Tags: Database

Similar Questions

  • How to create the validation for a composite primary key feature when I use create with operation of parameters to pass values to a page (i.e. the ADF table) to another page I get this error, how can I solve it. Please help me any one ASAP?

    Hello

    I have a page with adf faces table, I need to pass values to the table to another the inputfields page (both fields are composite primary keys), I'm passing values but I get the error while I'm passing values twice on the next page with a button command (using setPropertyListener) this error... Please help me?

    Houston-29114 ADFContext is not configured to process this exception messages. Use the code of exception stack trace and error to investigate the root cause of this exception. Root cause error code is Houston-25013. Error messages settings are {0 = oracle.jbo.Key [22 9]}

    ADF_FACES-60097: for more information, see the error log of the server for an entry beginning with: ADF_FACES - Exception during the PPR, #1 60096:Server


    The error log is...


    URL - target http://127.0.0.1:7101/Recruting-ViewController-context-root/faces/login.JSPX

    < ViewHandlerImpl > < _checkTimestamp > Apache Trinidad runs with control of activated timestamp. This should not be used in a production environment. See the org.apache.myfaces.trinidad.CHECK_FILE_MODIFICATION property in WEB-INF/web.xml

    < UIXEditableValue > < _isBeanValidationAvailable > Validation Bean A provider is not present, so bean validation is disabled

    passing the user name: 201157

    < _LogUnhandledException > ADF_FACES - 60098:Faces life cycle receives exceptions that are unhandled in phase 5 of INVOKE_APPLICATION

    oracle.jbo.TooManyObjectsException: Houston-25013: too many objects correspond to the oracle.jbo.Key [22 primary key 9].

    at oracle.jbo.server.EntityCache.throwTooManyObjectsException(EntityCache.java:608)

    at oracle.jbo.server.EntityCache.handleDuplicateKey(EntityCache.java:617)

    at oracle.jbo.server.EntityCache.addForAltKey(EntityCache.java:1030)

    at oracle.jbo.server.EntityCache.add(EntityCache.java:541)

    at oracle.jbo.server.EntityImpl.callCreate(EntityImpl.java:1141)

    at oracle.jbo.server.ViewRowStorage.create(ViewRowStorage.java:1140)

    at oracle.jbo.server.ViewRowImpl.create(ViewRowImpl.java:461)

    at oracle.jbo.server.ViewRowImpl.callCreate(ViewRowImpl.java:478)

    at oracle.jbo.server.ViewObjectImpl.createInstance(ViewObjectImpl.java:5800)

    at oracle.jbo.server.QueryCollection.createRowWithEntities(QueryCollection.java:1941)

    at oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(ViewRowSetImpl.java:2504)

    at oracle.jbo.server.ViewRowSetImpl.doCreateAndInitRow(ViewRowSetImpl.java:2545)

    at oracle.jbo.server.ViewRowSetImpl.createAndInitRow(ViewRowSetImpl.java:2510)

    at oracle.jbo.server.ViewObjectImpl.createAndInitRow(ViewObjectImpl.java:11133)

    at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1342)

    at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2169)

    at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:731)

    at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:402)

    at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)

    at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:210)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.sun.el.parser.AstValue.invoke (unknown Source)

    at com.sun.el.MethodExpressionImpl.invoke (unknown Source)

    at oracle.adf.controller.internal.util.ELInterfaceImpl.invokeMethod(ELInterfaceImpl.java:173)

    at oracle.adfinternal.controller.activity.MethodCallActivityLogic.execute(MethodCallActivityLogic.java:163)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.executeActivity(ControlFlowEngine.java:1091)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:982)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:880)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.routeFromActivity(ControlFlowEngine.java:553)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.performControlFlow(ControlFlowEngine.java:158)

    at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleAdfcNavigation(NavigationHandlerImpl.java:115)

    at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:84)

    at org.apache.myfaces.trinidadinternal.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:50)

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)

    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)

    at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:159)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:1137)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:361)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:202)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)

    to weblogic.servlet.internal.StubSecurityHelper$ ServletServiceAction.run (StubSecurityHelper.java:227)

    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)

    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:125)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:468)

    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:468)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)

    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to oracle.security.jps.ee.http.JpsAbsFilter$ 1.run(JpsAbsFilter.java:119)

    at java.security.AccessController.doPrivileged (Native Method)

    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)

    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)

    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)

    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)

    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.wrapRun (WebAppServletContext.java:3715)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.run (WebAppServletContext.java:3681)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)

    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)

    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)

    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    < RegistrationConfigurator > < handleError > ADF_FACES - 60096:Server Exception during the PPR, #1

    oracle.jbo.TooManyObjectsException: Houston-29114 ADFContext is not configured to process this exception messages. Use the code of exception stack trace and error to investigate the root cause of this exception. Root cause error code is Houston-25013. Error messages settings are {0 = oracle.jbo.Key [22 9]}

    at oracle.jbo.server.EntityCache.throwTooManyObjectsException(EntityCache.java:608)

    at oracle.jbo.server.EntityCache.handleDuplicateKey(EntityCache.java:617)

    at oracle.jbo.server.EntityCache.addForAltKey(EntityCache.java:1030)

    at oracle.jbo.server.EntityCache.add(EntityCache.java:541)

    at oracle.jbo.server.EntityImpl.callCreate(EntityImpl.java:1141)

    at oracle.jbo.server.ViewRowStorage.create(ViewRowStorage.java:1140)

    at oracle.jbo.server.ViewRowImpl.create(ViewRowImpl.java:461)

    at oracle.jbo.server.ViewRowImpl.callCreate(ViewRowImpl.java:478)

    at oracle.jbo.server.ViewObjectImpl.createInstance(ViewObjectImpl.java:5800)

    at oracle.jbo.server.QueryCollection.createRowWithEntities(QueryCollection.java:1941)

    at oracle.jbo.server.ViewRowSetImpl.createRowWithEntities(ViewRowSetImpl.java:2504)

    at oracle.jbo.server.ViewRowSetImpl.doCreateAndInitRow(ViewRowSetImpl.java:2545)

    at oracle.jbo.server.ViewRowSetImpl.createAndInitRow(ViewRowSetImpl.java:2510)

    at oracle.jbo.server.ViewObjectImpl.createAndInitRow(ViewObjectImpl.java:11133)

    at oracle.jbo.uicli.binding.JUCtrlActionBinding.doIt(JUCtrlActionBinding.java:1342)

    at oracle.adf.model.binding.DCDataControl.invokeOperation(DCDataControl.java:2169)

    at oracle.jbo.uicli.binding.JUCtrlActionBinding.invoke(JUCtrlActionBinding.java:731)

    at oracle.adf.controller.v2.lifecycle.PageLifecycleImpl.executeEvent(PageLifecycleImpl.java:402)

    at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding._execute(FacesCtrlActionBinding.java:252)

    at oracle.adfinternal.view.faces.model.binding.FacesCtrlActionBinding.execute(FacesCtrlActionBinding.java:210)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

    at java.lang.reflect.Method.invoke(Method.java:597)

    at com.sun.el.parser.AstValue.invoke (unknown Source)

    at com.sun.el.MethodExpressionImpl.invoke (unknown Source)

    at oracle.adf.controller.internal.util.ELInterfaceImpl.invokeMethod(ELInterfaceImpl.java:173)

    at oracle.adfinternal.controller.activity.MethodCallActivityLogic.execute(MethodCallActivityLogic.java:163)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.executeActivity(ControlFlowEngine.java:1091)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:982)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:880)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.routeFromActivity(ControlFlowEngine.java:553)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.performControlFlow(ControlFlowEngine.java:158)

    at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleAdfcNavigation(NavigationHandlerImpl.java:115)

    at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:84)

    at org.apache.myfaces.trinidadinternal.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:50)

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)

    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)

    at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:159)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:1137)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:361)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:202)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:508)

    to weblogic.servlet.internal.StubSecurityHelper$ ServletServiceAction.run (StubSecurityHelper.java:227)

    at weblogic.servlet.internal.StubSecurityHelper.invokeServlet(StubSecurityHelper.java:125)

    at weblogic.servlet.internal.ServletStubImpl.execute(ServletStubImpl.java:300)

    at weblogic.servlet.internal.TailFilter.doFilter(TailFilter.java:26)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adf.model.servlet.ADFBindingFilter.doFilter(ADFBindingFilter.java:173)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:125)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:468)

    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:468)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)

    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to oracle.security.jps.ee.http.JpsAbsFilter$ 1.run(JpsAbsFilter.java:119)

    at java.security.AccessController.doPrivileged (Native Method)

    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:315)

    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:442)

    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)

    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)

    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:139)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.wrapRun (WebAppServletContext.java:3715)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.run (WebAppServletContext.java:3681)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)

    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)

    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)

    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    Hi all, finally I found the solution to this exception.

    I did the following steps to solve the problem.

    1. create a bean and use this method

    public void tooManyObjectsMatchExceptioHandeler() {}

    Add the code in the event here...

    System.out.println ("inside the Handeler");

    FacesMessage message =

    new FacesMessage ("Type your friendly message");

    message.setSeverity (FacesMessage.SEVERITY_ERROR);

    FacesContext fc = FacesContext.getCurrentInstance ();

    fc.addMessage (null, message);

    }

    Now, drag and drop the file above java projects in data controls in the browser of the application.

    2. drag a workflow method call (where u get exception as Houston-25013) and call this method as an activity of the exception handler,

    Now, do a right click on this--> definition of the page method call create or go to definition of the page--> create a link Action method and select the above method in the select and file def page this method call in the workflow then go to properties inspector set out fixed property (here name of activities of method call) u give.

  • change a composite primary key


    Hello

    I have a table that has a composite primary key with 3 columns (col1, col2, col3)

    Now I need to change the primary key (col1, col2, col4) remove composite col3 replace with col4

    col1 col2 COL3 COL4 col5
    1onexpDFD
    1oneTherepDFD
    1onezpSD
    1onempamplifier
    1onenpTry

    There are thousands of records in the table in the format above. How to make this change?

    Thank you.

    In this case, you will need to establish that if the change to the primary key makes sense - if so, you'll have to remove some lines to remove duplicates. I think that if this requirement has been raised at a request of the company, they will (should) have indicated what lines need to be maintained.

    If it is not sensible, you will need to go to the one who asked for the change and get them to change their mind or tell you what to do with duplicate lines.

    Out of curiosity, why did you change the primary key?

  • How to create validation of business for a composite primary key

    Hi all

    I am newbie in oracle ADF and my knowledge is lacking in the validation of the company,

    My requirement is to display an error message when the user enter the same data into the table.

    Let me exaggerate I have a table which the composite primary key is defined on 2 columns, if the user does not have the composite primary key constraints, so I have to display the warning message.

    FYI, I use the version of Jdeveloper 11.1.2.3.0

    Please let me know the steps to create business for this rule.

    Thank you very much!!

    User, if you use adfbc, you have nothing to do because this behavior out of the box. When you create a model of your tables infrastructure creates the business rule for you.

    Timo

  • By specifying the Composite primary key (columns 4 and 5)

    Hi all

    I am new to Oracle Apex,

    I have a few paintings with a composite primary key (4 or 5 columns)... When I try to create a primary key constraint, it gives me only 3 columns!

    Any help please in how can I solve this problem?

    Thanks in advance

    You are probably using the workshop for this sql Object Explorer

    which seems to be limited to 4 columns on APEX 4.2.3

    best thing to do is to create manually using the sql commands in sql workshop, here's an example:

    {code}

    CREATE UNIQUE INDEX myui ON JC_ACCOUNT

    (TITLE_ID, FAMILY_NAME GIVEN_NAME, GENDER_ID, TELEPHONE_NUMBER)

    /

    {code}

    I hope this helps you

    KR

    Martin

  • identification of composite primary keys

    Hi mates,

    I am trying to identify a unique value in a particular table, so then I tried to look for the primary key of the table constraints:

    11:54:07 brunos@vvp > select constraint_name, constraint_type, index_name, owner of dba_constraints where table_name = 'CARD_TRANSACTIONS ';

    OWNER CONSTRAINT_NAME, CONSTRAINT_TYPE INDEX_NAME
    ------------------------------ ------------------------------ --------------- ------------------------------
    VVP PK_CARD_TRANSACTIONS P PK_CARD_TRANSACTIONS


    Then I looked at dba_cons_columns:

    11:56:22 brunos@vvp > select * from dba_cons_columns where constraint_name = "PK_CARD_TRANSACTIONS";

    OWNER CONSTRAINT_NAME TABLE_NAME COLUMN_NAME POSITION
    ------------------------------ ------------------------------ ------------------------------ --------------------------------------------------
    VVP PK_CARD_TRANSACTIONS CARD_TRANSACTIONS CARD 4
    VVP PK_CARD_TRANSACTIONS CARD_TRANSACTIONS METER 3
    VVP PK_CARD_TRANSACTIONS CARD_TRANSACTIONS 2 OPERATION
    VVP PK_CARD_TRANSACTIONS CARD_TRANSACTIONS STATE 1



    I understand that in a single table, we have only 1 PK only. It is a composite primary key? I expected to see 1 single value, and then he showed me 4.


    Thanks in advance.

    Published by: BSalesRashid on 06/29/2012 07:58

    It is a Composite key, you can see the column in position to observe order in the Composite key.

    Rgds,

    Ahmer

    Published by: Ahmer Mansoor on June 29, 2012 20:02

  • assign a Composite primary key

    Hi all

    I have the table with composite primary key (ID, year)
    I want to assign the value using triggers and sequence

    the number will start from 1 and current year to the end of the year and start again next year
    How can I do this

    Best regards

    Hello

    mkm802 wrote:
    Dear Frank

    How can please I use the ROW_NUMBER for this

    You have not posted the CREATE TABLE and INSERT statements for examples of data, so I'll use scott.emp:

    SELECT       ename
    ,       deptno
    ,       EXTRACT (YEAR FROM hiredate)     AS year
    ,       hiredate
    ,       ROW_NUMBER () OVER ( PARTITION BY  deptno
                                 ,          EXTRACT (YEAR FROM hiredate)
                          ORDER BY          hiredate
                        )           AS r_num
    FROM      scott.emp
    ORDER BY  deptno
    ,            hiredate
    ;
    

    Output:

    ENAME          DEPTNO       YEAR HIREDATE         R_NUM
    ---------- ---------- ---------- ----------- ----------
    CLARK              10       1981 09-Jun-1981          1
    KING               10       1981 17-Nov-1981          2
    MILLER             10       1982 23-Jan-1982          1
    SMITH              20       1980 17-Dec-1980          1
    JONES              20       1981 02-Apr-1981          1
    FORD               20       1981 03-Dec-1981          2
    SCOTT              20       1987 19-Apr-1987          1
    ADAMS              20       1987 23-May-1987          2
    ALLEN              30       1981 20-Feb-1981          1
    WARD               30       1981 22-Feb-1981          2
    BLAKE              30       1981 01-May-1981          3
    TURNER             30       1981 08-Sep-1981          4
    MARTIN             30       1981 28-Sep-1981          5
    JAMES              30       1981 03-Dec-1981          6
    
  • Composite primary key (reverse)

    Hello

    I created a table with composite primary key

    for example: -.
    create table demo (NUMBER one, NUMBER two, the key pk_composite primary (one, two);)

    Insert into demo values (1,2);
    1 row inserted

    Insert into demo values (1,2);
    ORA-00001: unique constraint (username. PK_composite) violated

    its ok...........................

    I know composite primary will not work reverse (i.e.)

    Select * from demo;
    one | two
    1. 2

    Insert into demo values (2,1);
    1 row inserted

    Select * from demo;
    one | two
    1. 2
    2. 1

    I need to do reverse, is it possible to make? (i.e.)

    Insert into demo values (2,1); -This should not

    Please help me... Thanks in advance...

    A quick way to do this is to create a unique index based on a function like this:

    create unique index demo_i1 on demo
    (least(one,two)
    ,greatest(one,two));
    
  • A composite primary key column cannot be null

    Hi all
    It will be a silly question, but still, I would like to ask if a composite primary key column can be null?


    Thank you
    Rafi.

    Rafi,

    Why you think he would be allowed?

    SQL> drop table test purge;
    drop table test purge
               *
    ERROR at line 1:
    ORA-00942: table or view does not exist
    
    SQL> create table test as select * from dba_objects;
    
    Table created.
    
    SQL> alter table test add primary key(object_id, owner);
    
    Table altered.
    
    SQL> insert into test(object_id, owner) values(null, 'aman');
    insert into test(object_id, owner) values(null, 'aman')
                                              *
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OBJECT_ID")
    
    SQL> insert into test(object_id, owner) values(1,null);
    insert into test(object_id, owner) values(1,null)
                                                *
    ERROR at line 1:
    ORA-01400: cannot insert NULL into ("SYS"."TEST"."OWNER")
    
    SQL>
    

    HTH
    Aman...

  • request for deletion with a composite primary key

    I have the following problem, which seems very simple, but I'm a bit at a loss :)

    I have a table T1 with composite primary key F1 and F2.

    There is a second table I want to use to delete records of T1 T2. It contains als F1 and F2.

    I want to do something like this
    delete from T1
    where T1.F1, T1.F2 in (select T2.F1, T2.F2 from T2);
    Of course, this does not work.

    There are solutions, but I find them unsatisfactory:
    -A loop of PL/SQL and passes the key one
    -Concatenate F1 and F2: where T1. F1 | T1. F2 to (select T2. F1 | W2M T2 F2); - but it's very ugly.

    Surely it must be possible in a simple SQL statement...

    Thank you!

    Rob
    delete from T1
    where (F1,F2) in (select T2.F1, T2.F2 from T2);
    

    Max
    [My Italian blog Oracle | http://oracleitalia.wordpress.com/2010/01/17/supporto-di-xml-schema-in-oracle-xmldb/]

  • Aggregation based on composite primary keys

    Hello

    I have a coherence cache which stores complex Java objects in the form of values in which I have to perform aggregation (County based on a composite primary key in the object). The key for the cache's UUID.
    For example:
    Class XYZ has properties a, b, c and d (all the java.lang.String type). I need to calculate the number of times a unique combination of values of a, b and c in the cache.

    I tried to use a ReflectionExtractor as:
    ReflectionExtractor[] xBiz = {new ReflectionExtractor(
              "getA"),new ReflectionExtractor(
              "getB"),new ReflectionExtractor(
              "getC")};
    Then, create a chained as Exractor:
    ChainedExtractor chExtractor = new ChainedExtractor(xBusinessService);
    Finally, I perform the aggregation such as:
    InvocableMap.EntryAggregator aggregator = GroupAggregator.Parallel
                        .createInstance(
                                  chExtractor,
                                  CompositeAggregator.Parallel
                                            .createInstance(new InvocableMap.EntryAggregator[] { new Count() }));
    Obviously something is wrong, but I get the exception:
    java.lang.RuntimeException: Missing or inaccessible method: java.lang.String.getB()
    When I do this for the aggregation based on a single property say a or b or c, the aggregation works very well:
    InvocableMap.EntryAggregator aggregator = GroupAggregator.Parallel
                        .createInstance(
                                  "getB",
                                  CompositeAggregator.Parallel
                                            .createInstance(new InvocableMap.EntryAggregator[] { new Count() }));
    with the result
    y1 -> 4
    for the sample data below.
    The expected result for Aggregetion based on several properties:
    Data in Cache:                Expected Result:
    A | B | C | D |                 x1,y1,z1  -> 2
    x1|y1|z1|Desc1|               x2,y1,z1 -> 1
    x2|y1|z1|Desc2|               x3,y1,z2 -> 1
    x1|y1|z1|Desc3|
    x3|y1|z2|Desc4|
    Can anyone comment on how to get the aggregate first? And also if the way I am using the extractor chained is correct.

    Thanks in advance
    Vikas

    Edited by: vikascv January 6, 2010 17:59

    I think you want to use a MultiExtractor who will then produce a table of the elements of the composite key on which you can then aggregate. This means that the array of items produced key can be properly evaluated for equality.

    If not, write a custom ValueExtractor which returns a single object (can be a concatenated string or a key object with equals/hashcode).

    Regards, Paul

  • How to define a Composite primary key for a Table

    Hello

    I'm basically more in Java programming, with little knowledge of Oracle bit as DataBase .so please sorry for my silly doubts.

    Can someone tell me please how to define a Composite primary key on a Table.

    Thanks in advance.

    Published by: user672373773 on 25 Sep, 2009 08:54

    Please go through these links:

    http://plsqlworld.blogspot.com/2009/01/oracleplsql-composite-primary-key.html

    http://sqlzoo.NET/HOWTO/source/z.dir/tip241027/Oracle

    Concerning
    Asif Kabir

    -Mark the response as correct/good

  • Entity object - Validation of Composite primary key

    Hi people,

    Can someone help me to implement this? I have a custom table created with an entity object based on that. However, this table has a PK composed of three columns of number. The developer's guide says that PK validation should be performed inside the setter for the attribute using findByPrimaryKey PK, because for a simple PK validation is level of attribute, but in this case, I have three bombers distinct and three distinct attributes of PK, which makes the PK cross-attribute validation.

    I tried to implement this in the validateEntity() because it is cross-attribute, but still, the validation fails. In my view, which is related to the fact that when validateEntity() fires, the entity itself is already in the cache, and the call to findByPrimaryKey() causes BC4J return a single game. Here is the code inside the validateEntity() for me:
            // First validation: Primary Key Uniqueness
            if (this.getEntityState() == STATUS_NEW || this.getEntityState() == STATUS_INITIALIZED) {
                EntityDefImpl def = PeriodEOImpl.getDefinitionObject();
                EntityImpl period = def.findByPrimaryKey(getOADBTransaction(), getPrimaryKey());
                if (period != null) {
                    // ERROR: DUPLICATE KEY FOUND
                    throw new OARowValException( OAException.TYP_ENTITY_OBJECT
                                               , getEntityDef().getFullName()
                                               , getPrimaryKey()
                                               , "MSG_APP"
                                               , "MSG_NAME" );
                }
            }
    Y at - it assumptions that I am causing that validation always fail? Is there anyone who had the same requirement and implemented a working solution to this? I looked through the dev guide and other sources, but this simple and common requirement seems to be forgotten.

    Thank you very much and it concerns!
    Thiago

    You make a transaction fictitious attribute in the EO and do a Composite key of four attributes instead of three. This additional attribute must ensure the automatic error of the OA framework is not present. Now you can enter commands using validateEntity. Don't bother abt the value stored in the temporary attribute because it would be lost anyway.

    Concerning
    Sumit

  • Update line programmatically with Composite primary keys

    Hi all

    I use JDeveloper 11.1.2.4.0,I want to update the program with two primary keys PK1_ID and PK2_ID line

    When I have a primary key I can do it by:

    /////////////////////////////////////////////////////

    Key = new key (new Object() {empid});

    Employees1ViewImpl vo = (Employees1ViewImpl) this.getEmployees1View1 ();

    Locate the line using key reference in the View object.

    Line k = vo.getRow (key);

    using this method, we can set the new FirstName

    k.setAttribute ("FirstName", "Vero");

    this.getDBTransaction () .commit ();

    ///////////////////////////////

    Is it possible to use the same code with more of primary key?




    Kind regards

    The key class contains an array of attributes that identify the line you're looking for. In your case, the key has two attributes

    Key = new key (new Object() {pkId1, pkId2});

    the rest of the method works as what.

    Timo

  • A composite primary key needs of the Unique ID column or not?

    Hello dear,
    I have a table that's the primary key is a key that is composed of two columns and there are like 5 columns of information. You think I'm going to use two columns as the primary key of this table or create a unique ID column.
    Example:
    Employees table:
    Services of table:

    The table of the problem is the Department managers:
    Now, I'll add employee id and service id in this table and Manager info etc... (info does not exist in the employee table), should I use as primary or create the id column in this table?

    Thank you very much.

    You must use the new ID as primary (alter table add constraint primary key,...) you cannot use foreign key as primary :)

Maybe you are looking for