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

Similar Messages

  • Creating a row trigger to populate the primary key

    to populate the primary key of a table automatically, i created a sequence named rule_id
    using the following statement:
    create sequence rule_id;
    and then i created a trigger to populate the primary key using the statements below:
    CREATE OR REPLACE
    TRIGGER RULE_ID BEFORE INSERT ON DOC_CATS_RULE_BASED_CLASS
    FOR EACH ROW
    BEGIN
    SELECT SEQ_RULE_BASED_CLASS.NEXTVAL
    INTO :new.id FROM DUAL;
    END;
    i took this from a books example. but it gives and error called:
    Error(3,8): PLS-00049: bad bind variable 'NEW.ID'
    What is wrong and what is the current way to do it?
    Please help!

    Hi ,
    The new denotes the new data values for the table relative column.....
    As regards the dual is a small table in the data dictionary that Oracle and user-written programs can reference to guarantee a known result. This table has one column called DUMMY and one row containing the value X.
    Regards,
    Simon

  • 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

  • How to create foreign key automatically?

    I am writing to seek help, in regards creating foreign key automatically, when I insert data into my ''price'' table.  I have 2 tables, one called prices and names.  the relationship between them, if that one name can have many prices and one price
    can have many names (many-to-many). Hence, i have junction table called  "Name_Prices", as shown below in the sample database schema:
    Names
    name_id [pk]
    name
    type
    UploadDate
    Prices
    Price_id [pk]
    name_id [fk]
    price
    uploadDate
    Name_Prices
    name_id REFERENCE names (name_id)
    price_id REFERENCE prices (price_id)
    PRIMARY KEY (name_id, price_id)
    The  price's data input comes in as CSV file everyday. (please see the example below) :
    name name_type price UploadDate
    ALBA MBS 93.5 17/10/2014
    ALESC Trup 58 17/10/2014
    ALESC Trup 52 17/10/2014
    My desire goal/output is to be able to create a functionality, where I can insert the price's data into the database (''prices''), it will automatically insert foreign key in the price
    table (from the names table), and if there is a new price's name, then the database will create a new name id for it, in the name's table, transferring the name, its type, from the CSV input data. 
    In order to achieve this task, where would I start implementing this logic?(in SQL server or application-side) what steps does this involve and is this task achievable, all in sql server side (i.e. store procedure, functions etc..). 
    Apology in advance, if the question is not clear to understand, i happy to follow up with further questions, if required.  
    Any help would be very appreciated. Many thanks

    As noted above, I modified the design:
    Products
    Product_id [pk]
    Product
    type
    UploadDate
    Prices
    Price_id [pk]
    price
    uploadDate
    Product_Prices
    Product_id REFERENCE Products (Product_id)
    price_id REFERENCE prices (price_id)
    PRIMARY KEY (Product_id, price_id)
    Note
    Kalman Toth Database & OLAP Architect
    SQL Server 2014 Database Design
    New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014

  • Master-Detail Forms (Populating a Foreign Key Automatically)

    Master-Detail Form
    When inserting a MD Form, the Master ID (e.g. Deptno,the Primary Key) is generated.
    How is it possible for this also to be generated in the Detail Form (as the Foreign Key)? The requirement is for the foreign key to be populated automatically.
    Any help would be much appreciated.
    Thanks.

    This item is discussed earlier in this group.
    It's solved in version 3.0.8
    Regards,
    Anna

  • Using a custom PL/SQL to populate the primary key in a tabular form

    I want to use a Custom PL/SQL Function to populate the primary key when I insert a new record into a tabular form. I want to get the value from a hidden page Item. The code I am using for the primary key source is:
    BEGIN
    INSERT INTO TEAM_MEMBERS(TEAM_ID)
    VALUES(:P75_TEAM_ID);
    END;
    When I try to insert a new record I get the following error:
    Error      ERR-1904 Unable to compute item default: type = Function Body computation_type= BEGIN INSERT INTO TEAM_MEMBERS(TEAM_ID) VALUES(:P75_TEAM_ID); END; .
    ORA-06550: line 5, column 2: PLS-00103: Encountered the symbol ";" when expecting one of the following: begin case declare end exception exit for goto if loop mod null pragma raise return select update while with << close current delete fetch lock insert open rollback savepoint set sql execute commit forall merge pipe The symbol "exit" was substit
    Any ideas what I am doing wrong?
    Thanks!

    Brian - Sometimes whitespace at the end of the block causes this. Be sure to trim everything after the last semicolon including tabs and newlines.
    Scott

  • 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?

  • How to populate the Language Key description is not available

    Hi,
    Question: How to populate the Language Key description is not available in the Customer text table
    The problem is ;
    Customer no : 0012345
    For this Customer no description is maintained only in EN, JA ,FR from R3 side.
    EN : HP International Ltd
    JP:HP &#12398;&#22269;&#38555;&#30340;&#12394;&#26666;&#24335;&#20250;&#31038;
    FR: Ltd International de HP
    There is no value for Language ES.
    BW side:
    User is login into language Key ES and executing the report based on this Customer no. There is no Customer text value maintained in language Key ES. It should populate the text value empty. BW system - Language ES is installed.
    I have a Reporting requirement is - I need to populate the text value for this customer No: HP International Ltd when the user login to language Key ES and execute his reports.
    /BI0/TCUSTOMER – Customer text table – I am able to see the description for the EN, JP, FR text values.
    EN: HP International Ltd
    JP: HP &#12398;&#22269;&#38555;&#30340;&#12394;&#26666;&#24335;&#20250;&#31038;
    FR: Ltd International de HP
    If the Customer text is not available in the text table of customer for language key ES - I have to populate the any one of the existing customer text values into the language key ES - example
    0012345 ES  HP International Ltd
    Simplest solution if we maintained ES customer description in R/3 should be ok.
    Is their any other logic which I can implement in BW.

    Hi,
    If you are opting to load Customer Text, there are two options:
    1. R/3 maintained.
    2. Generic Extraction using Flat Files.
    Hope it helps..
    Regards,
    GPK.

  • 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.

  • 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

  • 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.

  • 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.

  • 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());

  • 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

Maybe you are looking for

  • Issues with black psd files on black backgrounds when exported to PDF.

    Hello there, I'm having an issue since I upgraded to leopard and moved all my stuff from my old macbook pro (running OSX 10.4) to my new macbook pro (running OSX 10.5). CS3 didn't seem to have any problems before but now when I export an Indesign fil

  • Comp crashed while uploading music

    G4 crashed while uploading iTunes music ... I have about 11 out of 14 tracks ... how do I go about getting the rest of the album without being charged?

  • PSE 10 Panorama Error

    When I try to use the Panorama option in PSE10 I get an error which causes the program to close.  I've re-installed PSE 10, but the problem persists.  I'm using Windows 8.1.

  • Is third party password software still needed

    I use 1Password and it is a mess right now withe syncing because of where I purchased the same app versions from. App store & Agile bits is a no go. Lots of workarounds and I am tired of it. Do I still need it for banking online or is the Mac & Safar

  • SegoeUI (MS Vista System Font) on MAC OS 10.4

    Hey ladies and gentlemen. I have a font issue on OSX10.4.8. I copied from MS Vista RC1 the open type font 'segoeui' (as segoeui.ttf) to my OSX font book. The font isn't showing propper, witch means that I only get kind of arabic letters or some cursi