Identifying the Foreign Keys

How can I identify the Foreign Keys in a row ???
Regards,
Junior

How can I identify the Foreign Keys in a row ???Junior:
Are you referring to FKs of a View Row involved in a View Link? If so, a View Row could have multiple FKs if it is involved in multiple View Links.
By writing MT (middle-tier) code, you can get the attribute list from the View Link. Note that this logic is only available in MT. If you need this info in the client, you can write this logic in MT and export it as a custom method that can be called from client.
      // Get the list of view links that this VO ('vo')
      // is involved in.
      String[] vls = vo.getViewLinkNames();
      // Get the View Link object.
      ViewLink vl = myAM.findViewLink(vls[0]);
      // Get the View Link definition.
      oracle.jbo.server.AssociationDefBase vlDef = (oracle.jbo.server.AssociationDefBase)
           ((oracle.jbo.server.ViewLinkImpl) vl).getDef();
      AttributeDef[] attrs;
      // Get the source side attribute definitions
      attrs = vlDef.getAttributeDefImpls();
      for (int j = 0; j < attrs.length; j++)
         System.out.println("  Attr: " + attrs[j].getName());
      // Get the destination side attribute definitions
      attrs = vlDef.getOtherAttributeDefImpls();
      for (int j = 0; j < attrs.length; j++)
         System.out.println("  Attr: " + attrs[j].getName());

Similar Messages

  • I am unable to create the Foreign key

    Hi,
    I need to create the Foreign key which reffered to composite primary key.
    the following table structure
    Parent table
    DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE, CATEGORY, STATEMENT, USER_ID, RECORD_MODIFICATION_DATE
    Here composite primary key columns(DIVISION, PROJECT_NUMBER, COMPETITION_PROJECT_NUMBER, COMPETITIVE_STMT_TYPE, SEQUENCE)
    Child Table
    DIVISION          VARCHAR2 (4)          
    PROJECT_NUMBER          NUMBER (10)COMPETITION_PROJECT_NUMBER     NUMBER (10)          
    COMPETITIVE_STMT_TYPE          VARCHAR2 (2)          
    SEQUENCE     NUMBER (2)          
    CATEGORY          VARCHAR2 (100)     
    STATEMENT     LONG          
    USER_ID     VARCHAR2 (100)          
    RECORD_MODIFICATION_DATE     DATE     
    ALTER TABLE COMPETITION_STMT ADD (CONSTRAINT COMPET_STMT_FK_PROJ_NUM foreign key
              (PROJECT_NUMBER) REFERENCES PROD_COMPET_XREF (PROJECT_NUMBER));
    when i am trying to create foreign key i got this error
    ORA-02270: no matching unique or primary key for this column-list
    this is production issue Please help me.
    Thanks in advance
    Regards
    Kumar.s

    ALTER TABLE PROD_COMPET_XREF ADD (
    CONSTRAINT PROD_COMP_XREF_PK_DPNCPNCT
    PRIMARY KEY
    (COMPETITION_PROJECT_NUMBER, PROJECT_NUMBER, DIVISION, PRODUCT_LOC_INDICATOR)
    When you create a foreign key, it must reference a unique or primary key. The primary or Unique key must consist ONLY of those columns upon which the Primary key is based.
    You must Alter the table and add a Unique key if you want to keep your compsite primary key constraint. The Unique key must be for only the column that your foreign key references. Then try to recreate your foreign key.
    I doubt you will be able to add a foreign key because I suspect you might have multiple rows with the same value for this column based on your composite key; however, if you only intend for the project number to be listed only once and to be unique for each row, then the unique key may work or you may want to revist your primary key on this table. Perhaps you don't need it to be a composite PK???
    If you can't work around that, one thing you can do is build a table based just on PROJECT_NUMBER that contains details about the project number and have other tables reference that. That is, if you have multiple rows with the same project number in that table. You may already have one? Perhaps you can build your foreign key to reference that?

  • Disable all the foreign keys in a database

    Hy, what sql to use to disable all the foreign keys in a database and how to enable all them again. Thanks

    select * from dba_constraints where constraint_type = 'R' and status = 'ENABLED'
    ALTER TABLE table_name
    disable CONSTRAINT constraint_name;
    ALTER TABLE table_name
    enable CONSTRAINT constraint_name;
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' enable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute and save result for enable before disable
    select
    'ALTER TABLE ' || OWNER || '.' || table_name || ' disable CONSTRAINT ' || constraint_name || ';'
    from dba_constraints where constraint_type = 'R' and status = 'ENABLED';
    Execute result for disable.

  • How to retrieve the Foreign key information in Oracle

    I want to know how to retrieve the Foreign Key information in Oracle while using SQL Statement?
    I have use three SQL statement to retrieve such information, but the performance is very bad.
    The three SQL Statements are:
    Select constraint_name, r_constraint_name from all_constraints where constraint_type = 'R' and table_name = table1;
    Select column_name from all_cons_columns where constraint_name = cons1;
    Select table_name, column_name from all_cons_columns where constraint_name = r_ccons1;
    Do anyone know another method to retrieve the Foreign Key information which has better performance?

    These sql-statements don't seem very performance intensive. My guess is something is wrong with your database (unless you have millions of constraints). How many constraints do you have? how many concurrent users? What is your dictionary cach hitratio? (other hitratio?) memory problems? other tasks of the computer? is this query the only one being slow? etc.

  • Problem to insert id into the foreign key  php/mysql

    Hello all,
    I'm having rouble to understand the process and there is no tutorial about my problem anywhere
    I have two table:
    Table 1 (member) with id, name, phone etc
    Table2 (post) add_id, title, description, price, member_id
    I got a form to post the add and I need to insert the id of table 1 into my table 2 member_id zone
    Fisrt I did the recorset to get user id
    $colname_rsMember = "-1";
    if (isset($_SESSION['MM_Username'])) {
      $colname_rsMember = $_SESSION['MM_Username'];
    mysql_select_db($database_connect, $connect);
    $query_rsMember = sprintf("SELECT * FROM member WHERE username='".$_SESSION['MM_Username']."'")or die(mysql_error());
    $rsMember = mysql_query($query_rsMember, $connect) or die(mysql_error());
    $row_rsMember = mysql_fetch_assoc($rsMember);
    $totalRows_rsMember = mysql_num_rows($rsMember);
    This part is working and I'm able to retreive info via echo just for testing
    After this code I have my insert code
    if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form2")) {
      $insertSQL = sprintf("INSERT INTO add (title, `description`, price, member_id) VALUES (%s, %s, %s, %s)",
                           GetSQLValueString($_POST['title'], "text"),
                           GetSQLValueString($_POST['description'], "text"),
                           GetSQLValueString($_POST['price'], "text"),
                           GetSQLValueString($_POST['member_id'], "int"));
      mysql_select_db($database_connect, $connect);
      $Result1 = mysql_query($insertSQL, $connect) or die(mysql_error());
      $insertGoTo = "ok.php";
      if (isset($_SERVER['QUERY_STRING'])) {
        $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
        $insertGoTo .= $_SERVER['QUERY_STRING'];
      header(sprintf("Location: %s", $insertGoTo));
    Do I need to include hidden field in y form?
    I'm having the same error message. Col member_id can't not be null
    Any idea what I'm doing wrong?
    Thank You!

    When someone logs in, Dreamweaver creates a session variable called $_SESSION['MM_Username']. Use that session variable to create a recordset to get the user's ID, which can then be entered into the foreign key field of the child table.
    Dreamweaver automatically puts the code for recordsets immediately above the DOCTYPE declaration, so you will need to move it above the code for the Insert Record server behavior. So, it needs to be in this order:
    Recordset to get user ID
    Insert Record for child table

  • SSAS 2008 Linking two cubes on the foreign key between two fact tables

    Hi, all -- 
    I have two cubes:
    Cube 1 has Fact1 (F1, "Events") and 3 dimensions (D1, D2, D3)
    Cube 2 has Fact2 (F2, "Sales") and 3 dimensions (D4, D1, D6)
    As you can see, two cubes reuse D1 as their common dimension.  In addition, F2 foreign keys into F1, e.g. F1 is "Events", and F2 is "Sales".  Every "sale" is an "event", but not every "event" is
    a "sale".
    The question is, how to I link the two cubes and their two respective fact tables on the foreign key?
    Thanks, Austin.

    Hi Austin,
    According to your description, you want to retrieve data from two different cubes, right? In Analysis Services, to query multiple cubes from a single MDX statement you can use the LOOKUPCUBE function (you can't specify multiple cubes in your FROM statement).
    The LOOKUPCUBE function will only work on cubes that utilize the same source database as the cube on which the MDX statement is running. For the detail information about it, please refer to the link below to see the blog.
    Retrieving Data From Multiple Cubes in an MDX Query Using the Lookupcube Function
    If I have anything misunderstood, please point it out.
    Regards,
    Charlie Liao
    TechNet Community Support

  • Populate the foreign key automatically

    HI All!
    I have a form in which there are two data blocks One is emp_master and other is salary_details.I have a foreign key salary_code in Emp_master and similarly Salary_code as primary key in salary details.I have used two list item in place of Emp_id and Salary_code.I want that when I select the emp_id as 10 from the list automatically salary_code list item should get populated by 1 item in the list item.Similary the rest should follow .Please someone look into this matter it would be a gr8t help to me.
    Thanks

    Abha,
    I would not use list items for this. Instead, use a multi-record text box with a scroll bar. It looks and behaves like a t-list, but is much easier to code and manage.
    Use the datablock wizard to create the master-detail relationship. When you use the wizard, all the code will be generated for you. Then use the layout wizard, and display multiple records with scroll bars.
    BTW, it is customary to have the primary key in the master, and the foreign key in the details. In your case it is backwards.
    Also see
    http://www.oracle.com/technology/obe/obe_as_10g/bi/forms/formsmasterdetailobe.htm

  • HOWTO: get JDev to show the foreign keys in Conn Nav & struct window

    Hi,
    I have SQL tables with foreign keys but the JDev connections navigator and table editor dont show them. They just look like primary keys in the "PK" column. The structure window shows a bunch of constraints with names like "SYS_C00143114" which is not very meaningful to me. Surely JDeveloper knows what these magic numbers mean and can trace the foreign keys for me.
    How can I get JDeveloper to show the foreign keys, and which table is referenced by that foreign key? Can I make it navigate from a table's foreign key value to the the correct tuple in the referenced table?
    Maybe this is an ER if JDev doesn't do this already. Navigating a schema, or drawing it showing all the foreign key references would be very handy. Navigating through actual table data would be nice too.
    Cheers,
    Simon.

    I found "new->Database Diagram" that does a lot of what I wanted, at least in mapping out the foreign key references. Now if I can just figure out how to print a .png file...
    It would still be nice for the connection navigator to trace them also.

  • 'how to identify the option key'

    pls can someone help me identify the 'option key' on my computer?

    That means the key with the symbol ⌥
    From left to right:
    fn ctrl ⌥ 
    and this is not a key but a smily :-)
    marek

  • Where the foreign key constraint is being physical store? Which tablespace?

    Hi,
    anyone got any idea where the foreign key constraint is being physical store? Which tablespace?
    Thank You...

    A foreign key constraint itself is purely logical -- there is no storage associated with it other than it's definition being stored in the data dictionary tables. If there is an index on the referencing column(s) then you can see where it is stored from the user_indexes view, although strictly speaking it's not part of the FK itself.

  • How to customize the foreign key constraint exception

    Hi All,
    I have two table, A and B.
    B.ref is foreign key references to A.id in database.
    Now I want to delete a row of table A in screen, error messages are :
    "Constraint "xxx.xxxx_S_FK1" is violated during post operation "Delete" using SQL statement "DELETE FROM xxxxxx WHERE xxxxxxxxx" and "ORA-02292: integrity constraint (xxx.xxxx_S_FK1) violated - child record found"
    How do I customize this error message? Is it possible to do it in EO Validation?
    Thank you!

    You can override the DoDML() method in EntityImpl something like follows
    @Override
    protected void doDML(int i, TransactionEvent transactionEvent) {
    try
    super.doDML(i, transactionEvent);
    catch(DMLConstraintException _ex) {
    if(_ex.getErrorCode().equals("26048") ) {
    // handle your exception
    sid

  • How to update the foreign key in a 1-to-many relation ?

    I have Product mapped to Channel as 1-1, and Channel mapped to Product as 1-M. Product has a nullable channel_id_fk as a foreign key to Channel, (so one can optionally specify or change the channel of a specific product).
    Starting with a specific product with a null channel_id_fk, I
    1) add this product to a channel (with a vector of products via ValueHolderInterface);
    2) set the channel of this product; and
    3) update the channel in a unit-of-work.
    The product.channel_id_fk doesn't get updated in db.
    I tried setting each side of the relation as read-only, but still it doesn't work.
    What am I missing ?
    (I am using toplink 9.0.4)

    More info:
    1) There is only a single uow involved, so there is no nested transaction.
    2) I tried checking the "target foriegn key" in the 1-1 mapping from Product to Channel, but this resulted in a exception thrown during runtime when the channel is accessed from the product:
    Local Exception Stack:
    Exception [TOPLINK-6094] (OracleAS TopLink - 10g (9.0.4) (Build 031126)): oracle.toplink.exceptions.QueryException
    Exception Description: The parameter name [AFFINITY_CHANNEL_ID_FK] in the query's selection criteria does not match any parameter name defined in the query.
    Query: ReadObjectQuery(au.com.agl.application.scorecard.AffinityChannel)
         at oracle.toplink.exceptions.QueryException.parameterNameMismatch(QueryException.java:658)
         at oracle.toplink.internal.expressions.ParameterExpression.getValue(ParameterExpression.java:149)
         at oracle.toplink.queryframework.SQLCall.translate(SQLCall.java:334)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:129)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.executeCall(CallQueryMechanism.java:111)
         at oracle.toplink.internal.queryframework.CallQueryMechanism.selectOneRow(CallQueryMechanism.java:584)
         at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRowFromTable(ExpressionQueryMechanism.java:792)
         at oracle.toplink.internal.queryframework.ExpressionQueryMechanism.selectOneRow(ExpressionQueryMechanism.java:763)
         at oracle.toplink.queryframework.ReadObjectQuery.execute(ReadObjectQuery.java:340)
         at oracle.toplink.queryframework.DatabaseQuery.execute(DatabaseQuery.java:498)
         at oracle.toplink.queryframework.ReadQuery.execute(ReadQuery.java:111)
         at oracle.toplink.publicinterface.Session.internalExecuteQuery(Session.java:1968)
         at oracle.toplink.threetier.ServerSession.internalExecuteQuery(ServerSession.java:629)
         at oracle.toplink.publicinterface.Session.executeQuery(Session.java:1096)
         at oracle.toplink.internal.indirection.QueryBasedValueHolder.instantiate(QueryBasedValueHolder.java:52)
         at oracle.toplink.internal.indirection.DatabaseValueHolder.getValue(DatabaseValueHolder.java:63)
         at au.com.agl.application.scorecard.ProductDetails.getExclusiveAffinityChannel(ProductDetails.java:69)
    ....

  • To check the foreign keys

    i need to know the table which gives a mapping of foreign keys...that is the key name its own table and then the table to which it is mapped as a foreign key

    Hi 477390,
    Here is the query.
    col "Primary Table" forma a30
    col "Primary Key constraint" forma a30
    col "Child Table" forma a30
    col "Reference Key constraint" forma a30
    select a.table_name "Primary Table"
         ,a.constraint_name "Primary Key constraint"
         ,b.table_name "Child Table"
         ,b.constraint_name "Reference Key constraint"
    from      dba_constraints a
         ,dba_constraints b
    where a.constraint_name=b.r_constraint_name
    and a.owner='<SCHEMA_NAME>';
    Cheers,
    Kamalesh JK

  • Display the foreign keys and primary keys in hirarchy qeury  please ?

    Any sql query to get the following columns:
    I should display all the master table names,it's primary key field and its foregin key field,the name of the foreignkey'table.
    This should be displayed in hirarchy i.e. it should start from the top level table like upside down tree.
    can we query the database like this
    thanx in advance
    prasanth a.s.

    hi there,
    Please can any body help in this query!
    Thanxs in advance
    prasanth a.s.

  • Ssis package error need help to fix it. though disabled all triggers and droped all the foreign keys and truncated tables on pipeline constraints.

    [PartyName1 [6672]] Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.
    An OLE DB record is available.  Source: "Microsoft SQL Server Native Client 11.0"  Hresult: 0x80004005  Description: "Transaction (Process ID 1414) was deadlocked on lock resources with another process and has been chosen as the
    deadlock victim. Rerun the transaction.".

    you need to provide Details about your package like what is source/destination.. any SQL query/where is the exact deadlock point.
    Please check the following links which may help you.
    http://blogs.technet.com/b/fort_sql/archive/2011/12/12/get-rid-of-deadlocks.aspx
    http://msdn.microsoft.com/en-us/library/ms191242.aspx
    Let us TRY this |
    My Blog :: http://quest4gen.blogspot.com/

Maybe you are looking for

  • My daughter bought song on her ipod touch but its not in our library how do we get it into the library?

    My daughter bought a song on her ipod touch, but it doesnt come up on our library. How do we get the song on our library?

  • InDesign CS6 Spell Check

    I cannot find a spell check anywhere in inDesign CS6. I have checked all drop down menus and sub menus and preferences and there is no mention of spell check anywhere.

  • Outbound IDOC for CLFMAS

    Hi All, I am sending Outbound IDOc for CLFMAS through BD93 T-code. But it is sending all the IDOCS  for Classification created earlier against vendor. I want to send only selected one. Please let me know how it can be achieved. Thanks, Anuj

  • Third-party Components not loaded in Flash CS3

    Hello, I am using Adobe Flash CS3 on Mac Ox. I have downloaded and installed several components throught he Extension manager wich reports they are correctly activated. When I launch Flash the components are not listed in the Components panel. I have

  • AVI files aren't displaying video in Premiere cs5, audio only.

    I've tried encoding/converting the like another user suggested in this thread Download and install VLC. In the folder containing your AVI files, create a new text document called "avi2mp4.bat" (without the quote marks). Be sure it has the .BAT extens