Autofill detail block based on query

Hi experts/Gurus
I have 3 tables
1-pr_mst
2-pr_trn
3-hr_mst
Em_code is a common key between theses tables.
on my form table 1 and 2 are the base main tables, due to the relationship, when i enter em_code on table 1 and query it, it shows data on both the table. Its a normal behavior in Master Detail block in forms.
When user enter em_code at form and there is no data found in table 2, obviously it show blank data block related to the table 2 and shows data in table 1 block, now i want an em_code details which stores in the table 3 automatically load in memory and populated in detail block.
Is it possible ? and how can i do this. suggest me a best or anybody can give example on emp/dept
regards
Anwer

I'm not sure if i understand you correctly. You want to have an additional relation between block 1 and block 3? If so, just create it, each block can have more than one relation as master.

Similar Messages

  • Calculation in a detail block based on condition

    Hi guys,
    Well I want to calculate the SUM of some records in a detail block based on a condition.
    Like my block that is based on a table consist these fields,
    FUND_ID, NOMINEE_ID, FUND_PERCENTAGE
    Now I want to validate record the percentage user enter for each fund must not exceed 100%.
    Like for FUND_ID = 1 the number of records user enter for this FUND_ID 1 in the detail block in the percentage field must not increase 100% - like user can enter multiple record and any ratio of percentage. Like for rec1 FUND_PERCENTAGE can be 50% for rec2 its again 50%.
    In the same Block user can also enter percentage of the FUND_ID = 2 but I have to calculate for each FUND_ID.
    How can I calculate the fields based on a condition in a detail block.
    Pliz help,
    Imran

    referesing my question....

  • Update detail block based on FROM QUERY

    I have 2 blocks in master-detail relation. The master is based on a table, the detail on from query. The Insert works fine... but whenever i want to update any field from the detail block, the items (text, lists, whatever) don't allow any updating.
    Is there some workaround?
    Thank you for the help
    NR

    RTM on blocks based on from-query.
    If I recall well, it says that you shoud write the DML code in on-insert, on-update and on-delete triggers - and, anyway, if I do not remember well the manual, that's what I do.
    So, the on-insert trigger should have an insert into <my_dml_table>...
    The on-update trigger sould have an update <my_dml_table>... where ... And there's a thing: you may have the rowid of <my_dml_query> fetched - which would be the best - or use some primary key for that table for update (not so good performance).
    The on-delete trigger somewhat like the on-update trigger.
    Moreover, I believe it would be better to have procedures for on-insert, on-update and on-delete grouped in one package in the database - again, this is what I use to do.

  • Recommended best practice to fetch detail block based on procedure

    HI
    I am creating a detail block (Dept)based on procedure which will be populated from the value from master block 'Emp'.
    For example,
    Detail block 'Dept' will be populated by calling procedure populate_detail(:emp.empno in number,dept.deptno out number) .
    But what are the triggers I need to call to populate detail block and at which level?
    I was thinking to call a WHEN-MOUSE-DOUBLECLICK on master block 'Emp' level to populate the detail block 'Dept' by calling the procedure and passing emp.empno as the parameter whenever the user moves from one master record to another.
    Please advise.
    Thanks in advance.

    Download the forms 6i examples CD from the OTN website

  • Set enabled in detail block based on record's data

    Hi,
    I have a detail block in tabular form(4.5).There is only one column "Hobby" which is disabled at design time and 4 records are displayed like as shown:
    - Hobby -
    Soccer
    Baseball
    Icehockey
    Basketball
    At run time I want to enable the records so that users can update it only if the hobby starts with letter 'B'.
    I tried using set_item_property in post query but this will enable all records as the last record starts with "B" and the code will enable the column.

    Try putting same trigger coding in WHEN-RECORD-INSTANCE
    Message was edited by:
    rajs

  • Building a block based on query

    Hi,
    I've to build a block containing empnumbers from emp table for the emp names entered by the user.
    EX: If emp enters SMITH,KING in a text item ,I've to build a mutlirecord block containing emp numbers of these emp names.
    I know I've to use EXEC_SQL package to achieve this.
    Ex is below:
    PROCEDURE getData1 IS
    connection_id EXEC_SQL.CONNTYPE;
    cursorID EXEC_SQL.CURSTYPE;
    sqlstr VARCHAR2(1000);
    loc_ename VARCHAR2(30);
    loc_eno NUMBER;               
    loc_hiredate DATE;
    nIgn PLS_INTEGER;
    nRows PLS_INTEGER := 0; -- used for counting the actual number of rows returned
    i integer:=0;
    type l_emp is table of emp%rowtype index by binary_integer;
    l_empvar l_emp;
    BEGIN
    connection_id := EXEC_SQL.OPEN_CONNECTION('scott/tiger@afresrtm');
    cursorID := EXEC_SQL.OPEN_CURSOR(connection_id);
    sqlstr := 'select empno from emp where ename in :text_item' ;
    EXEC_SQL.PARSE(connection_id, cursorID, sqlstr, exec_sql.V7);
    --EXEC_SQL.BIND_VARIABLE(connection_id, cursorID, ':bn', input_empno);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 1, loc_ename, 30);
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 2, loc_eno);     
    EXEC_SQL.DEFINE_COLUMN(connection_id, cursorID, 3, loc_hiredate);
    nIgn := EXEC_SQL.EXECUTE(connection_id, cursorID);
    -- call FETCH_ROWS to obtain a row. When a row is returned, obtain the values,
    -- and increment the count.
    WHILE (EXEC_SQL.FETCH_ROWS(connection_id, cursorID) > 0 ) LOOP     
    nRows := nRows + 1;
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 1, loc_ename);
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 2, loc_eno);     
    EXEC_SQL.COLUMN_VALUE(connection_id, cursorID, 3, loc_hiredate);
    l_empvar(i).ename:=loc_ename;
    l_empvar(i).empno:=loc_eno;
    l_empvar(i).hiredate:=loc_hiredate;
    i:=i+1;
    END LOOP;
    IF (nRows <= 0) THEN
    TEXT_IO.PUT_LINE ('Warning: query returned no rows');     
    END IF;
    for i in 1..l_empvar.last loop
    :emp.ename:=l_empvar(i).ename;
    :emp.empno:=l_empvar(i).empno;
    :emp.hiredate:=l_empvar(i).hiredate;
    create_record;
    next_record;
    end loop;
    END;
    Here is a pbm in SQL query:
    How can I prepare a sql stmt for the input given by user bcoz it has to be varchar.
    Pls give me a sol..
    Adios..
    Prashanth Deshmukh

    Hi,
    I've not tried this and can't say for sure if it is possible or not.
    But, have a look at this link Re: Automatic  Number  of record displayed .
    I'd thought of a solution but never tried myself. Try if it works for you.
    If it doesn't, i think it will not be possible in oracle forms.
    Navnit

  • Searching master block based on value in detail block

    I have two blocks on a form. A master block for purchase orders and a detail block for the line items. I need to provide users with the ability to search the purchase orders based on the values entered into the detail block (line items), during the query entry. I am considering to check to see which block the cursor resides by using the :SYSTEM.CURSOR_BLOCK variable, then retrieving the value from the current item and running a query, using that query. The problem is that I am not very familiar with Forms and do not know how to implement my idea. Any ideas?
    null

    I copied you an example from metalink. Hope it will help.
    Doc ID:
    Note:109583.1
    Subject:
    How to query a Master record from a Detail Block
    Type:
    BULLETIN
    Status:
    REVIEWED
    Content Type:
    TEXT/PLAIN
    Creation Date:
    22-MAY-2000
    Last Revision Date:
    03-AUG-2001
    PURPOSE
    ------- To query a master record from a detail record. DESCRIPTION
    =========== The user would like to enter a query criteria in the detail block
    and then query the master record based on the above user input. SOLUTION
    ======== Create the master and detail blocks and the relationship in the usual
    manner. We will consider here the blocks DEPT and EMP based on the
    SCOTT schema. 1. Create a KEY-ENTQRY trigger at the block level of the detail block
    (EMP) and add the following code in it : GO_BLOCK('dept');
    CLEAR_BLOCK(no_commit);
    GO_BLOCK('emp');
    ENTER_QUERY; 2. Create a KEY-EXEQRY trigger for the detail block and add
    this : EXECUTE_QUERY;
    :global.deptno := :emp.deptno;
    :global.flag := 'T';
    GO_BLOCK('dept'); This will store the value of the deptno (primary key) in a global variable
    :global.deptno and set another global variable :global.flag to 'T'. This
    will be explained as we progress. 3. Create a WHEN-NEW-RECORD-INSTANCE trigger for the detail block
    and add the following : -- This is used to populate the MASTER block with the corresponding
    -- record whenever the user navigates through all the records in the
    -- DETAIL block if get_record_property(:system.cursor_record,:system.cursor_block,status) = 'QUERY' then
    SELECT rowid,deptno,dname,loc
    INTO :dept.rowid,:dept.deptno,:dept.dname,:dept.loc
    FROM dept
    WHERE deptno = :emp.deptno; -- This is to set the status of the record populated
    -- to QUERY and not to create a new record SET_RECORD_PROPERTY(1,'dept',status,QUERY_STATUS);
    end if; 4. Create a WHEN-NEW-BLOCK-INSTANCE trigger for the master block again
    and add this : if :global.flag = 'T' then -- set the variable to a different value
    :global.flag := 'F';
    :dept.deptno := :global.deptno; -- This will query the master table for the record based on the
    -- deptno of the detail table which is stored in :global.deptno -- For ex: if an employee of department 10 has been queried in
    -- the detail, then the global.deptno will have the value 10,
    -- which is used in the query below to fetch the master record. SELECT rowid,deptno,dname,loc
    INTO :dept.rowid,:dept.deptno,:dept.dname,:dept.loc
    FROM dept
    WHERE deptno = :global.deptno;
    set_record_property(:system.cursor_record,'dept',status,QUERY_STATUS);
    GO_BLOCK('emp'); end if; EXPLANATION
    =========== Actually in the above method we are using the base table blocks as a
    non-base table block when we query the master from detail. We are
    displaying the master record fetched from the table based on
    the query supplied in the detail. So after the fetch, if we clear the
    block or form then we get a "Do you want to save the changes you have made"
    alert. So in order to supress this while entering a normal master-detail
    query, we have created the global variable, :global.flag. There is a limitation though, if you query detail records and then
    navigate to the master block and then press the down arrow( i.e.,
    navigate to the next record) and then presses the up arrow to
    navigate back to the same record, then the detail records that
    were originally populated will change and a new set of records will
    get displayed. This is because the normal master-detail query is
    taking place during MASTER record navigation. This can be controlled by creating a flag (global variable) and setting
    its value and thus preventing the user from navigating to the next master
    record. Do the following : 1) In the KEY-EXEQRY trigger of the detail add the following :global.control_master := 1; 2) Create a KEY-EXEQRY for the master and add this : :global.control_master := 0;
    EXECUTE_QUERY; 3) Create a KEY-DOWN in the master with the following in it: IF :global.control_master <> 1 THEN
    down;
    END IF; Declare all the global variables before running the Form. RELATED DOCUMENTS
    Note:611.1

  • Detail blocks in tab pages not queried automatically

    Hi
    I have some generated forms with the following layout:
    - in the content canvas top, the master block
    - below the master block (in the same content canvas), a tab canvas with 2 (or more) pages with detail blocks
    When I query the master block, the detail blocks are not automatically queried, the user must navigate to them to make the automatic query work.
    I found out that it is something related to the blocks not being in the same canvas. But visually, they are in the same canvas, I would like that the detail blocks were queried automatically.
    Is this possible? I think this layout is very common and useful, I am sure Designer has some way to do this.
    Thanks
    Luis Cabral

    Hi
    I found it - I just set BSCSCP preference correctly, and now it works fine!

  • Setting check box (in detail block) as (non) updatable...

    Hi,
    I have a master-detail form. The form does execute a query when it opens. Now, according to a condition i want to do the check box(in detail block) as non- updatable.
    I have tried to write the appropriate code in:
    WHEN-NEW-RECORD-INSTANCE(in the master block level)
    WHEN-NEW-ITEM-INSTANCE (in the detail block level)
    POST-QUERY(in the detail block level)
    but it does not work 'perfectly'. I mean that in most cases even one of the above triggers does not execute (for example the 'WHEN-NEW-RECORD-INSTANCE' but only after i click on this new record instance. I mean that after this on this new record the condition is estimated....)
    or
    it does execute but after i click on the checkbox (for example the 'WHEN-NEW-ITEM-INSTANCE').
    The code i tried looks like the following:
    if :block.item=<condition>
    then
      set_item_property ('detail_block.chk_box',updatable,property_false);
    else
    set_item_property ('detail_block.chk_box',updatable,property_true);
    end if;I consider to use the WHEN-CHECKBOX-CHANGED trigger and code which looks like:
    if <condition>=true
    then
        /*i set the value of the checkbox as the opposite of what it is just after the click on it...*/
      if :detail_block.chk_box=0
       then
         :detail_block.chk_box=1;
      else
        :detail_block.chk_box=0;
      end if;
      set_record_property(currect_record,status,query_status);
      set_item_property ('detail_block.chk_box',updatable,property_false);
    end if;The truth is that i do not like very much this code, but is there any alternative...???
    Note: I use Dev6i with patch 12
    Thank you,
    Sim

    I build a little testform based on HR-schema-table DEMO_USERS and switch each second record to be not updateable, works without problems (code from POST-QUERY-trigger):
    DEFAULT_VALUE('1', 'GLOBAL.SWITCH');
    :GLOBAL.SWITCH:=3-:GLOBAL.SWITCH;
    IF :GLOBAL.SWITCH=2 THEN
      SET_ITEM_INSTANCE_PROPERTY('DEMO_USERS.ADMIN_USER', TO_NUMBER(:SYSTEM.TRIGGER_RECORD), UPDATE_ALLOWED, PROPERTY_TRUE);
    ELSE     
      SET_ITEM_INSTANCE_PROPERTY('DEMO_USERS.ADMIN_USER', TO_NUMBER(:SYSTEM.TRIGGER_RECORD), UPDATE_ALLOWED, PROPERTY_FALSE);
    END IF;     Edited by: Andreas Weiden on 31.03.2009 21:24

  • PRE_INSERT IN DETAIL BLOCK IS NOT WORKING

    Hello,
    I Have a master detail form and on the detail block I need to insert record in the mtl_transaction_interface table, I have placed the query in the pre-insert of detail block but this query is not executing, if I execute the same query on SQL Prompt then its working fine, while in form , In the pre-insert of detail block its not inserting record in the interface table, how can i check for any problem, I am sure there is no problem with the query, I just cant find the exact event where to place this query, I am also using the COMMIT at the end as well,, but no luck

    Hi,
    You detail block is based on based on which table? If your detail block is based on mtl_transaction_interface table you can use your forms to create a new record and just using the save button will do the work. If its not the case the pre-insert will work only when you add a new record to the detail block.
    Check if your pre-insert trigger is fired with a message so you know pre-insert event is happening.
    Regards
    Yoonas

  • Unable to see the values in detail block

    Hello,
    I have a master detail block, when I query the form, I am unable to see the values for a particular field(Column), all other columns appear properly in the details block, Upon checking the same table(s) in SQL ( by using the JOIN defined in the where clause of the relationship in Forms) , it shows the relevant records for all fields. So what could be wrong with the Form, please advise.
    Thanks
    FM

    IQ wrote:
    I have just checked the field its a non-database field which is being used as a LOV column to display a value derived from LOV. How do I make this populate at Query time, as obviously this works when the Form is in a insert mode but not for Query mode. How to make it work for Query ? As it for LOV column and non-database filed, ignore my first suggestion.
    Does your non-database filed has associate any column ?
    For example, you have SUPPLIER_ID (database column) and SUPPLIER_NAME (non-database column). SUPPLIER_NAME has LOV column. And when selecting supplier name from LOV value also assign at supplier_id.
    Now to show supplier name when querying, you have to write POST-CHANGE trigger at supplier_id. like
    SELECT ASSC_CODE INTO :MST_SUPPLIER.ACC_CODE
    FROM ACC_SUB_SUB_CONTROL
    WHERE ASSC_ID=:MST_SUPPLIER.SUPP_ASSC_ID;Hope this helps

  • Master - detail block (many-to-many)

    Hello, , I have 2 tables:
    1-(parts)its primary key : p_id
    2-(suppliers)its primary key : s_id
    and they have many-to-many relationship between them .
    the table Resulted from the relationship is(part_supp)
    How can I create master-detail block Based on this relationship.In other words, which of tables will be the master and which of them well be detail.
    I am using form 6i ..
    please help.....

    M3ATH wrote:
    Hello, , I have 2 tables:
    1-(parts)its primary key : p_id
    2-(suppliers)its primary key : s_id
    and they have many-to-many relationship between them .Many to many relation between two table isn't a good database design. You have to a junction table between them.
    the table Resulted from the relationship is(part_supp)Is this your junction table(part_supp) ?
    >
    How can I create master-detail block Based on this relationship.In other words, which of tables will be the master and which of them well be detail.If part_supp is your junction table between parts and suppliers then, try this..
    Use the junction table as a hidden block, then establish a standard Forms relation between
    Parts and (hidden)part_supp then between part_supp and suppliersHope this helps

  • [Forms 10] How to activate all buttons in a details block?

    Hi,
    I have a details block based on products. (10 lines)
    I have a block_buttons with a button on the same canvas.
    I set the block_buttons number of records to 10 so that the buttons and the records are aligned.
    [prodno] [button] <-- active
    [prodno] [button] <-- disabled
    [prodno] [button] <-- disabled
    [prodno] [button] <-- disabled
    [prodno] [button] <-- disabled
    At the moment only the first button is active.
    The 9 buttons under it are disabled.
    I can't find if I have to set a property or to write code to enable the 9 buttons under the first one.
    Thanks for your help.

    Hi,
    I have managed to get the buttons list to be actve.
    I have created a testbuttons table with a chkbx column.
    I added a checkbox list to the block.
    The button can't be a database item, but the checkbox can.
    Then if I execute_query on that block all items are activated.
    Now I'll try creating a PLSql table on the client side and try using it as support for the control block.

  • Query forms based on detail block

    My question is pretty simple: Is it possible to query a form (Forms [32 Bit] Version 6.0.8.11.3) based on a detail block? Let me explain my problem! I have a table called REQUISITION and of its field is STATUS_CODE. Then I have another table called STATUS that have the following fields: CODE, NAME, DESCRIPTION, PHASE, etc. The join condition between REQUISTION and STATUS is REQUISITION.STATUS_CODE = STATUS.CODE. On my form, all of the fields come from table REQUISITION but the problem is that we have over 30 different status and my user can't remember their names and phase. So I inserted two display fields on the forms and wrote a post-query trigger to populate the field with their corresponding names and phases. But now my end user are complaining that the fields don't allow queries to be performed which prevents them to use a query to know all requisitions that are on phase "Procurement" which corresponds to four different status_code. So I though in inserting the fields PHASE and DESCRIPTION into table REQUISITION and write a trigger that would populate those field every time the STATUS change but that would cause a problem when lets say STATUS 01 is part of PHASE "Procurement" then comes next week the company decides that is not longer part of phase "Procurement" but now it is part of PHASE "Purchasing" they would go the form based on table STATUS and change the field PHASE of the corresponding STATUS that they want. But now I have this data on another table holding information that is no longer valid. Sure I could write another trigger to change field REQUISITION.STATUS_PHASE whenever there is a change on STATUS.PHASE but wouldn't that be too much bookkeeping? Would be so much easier if I could query my forms based on the detail block (this case table STATUS and master block table REQUISITION)?
    thanks so much in advance for any thought! Btw, I am open to other suggestions too!!!!!
    gleisson henrique

    if I understood you correctly, you can do this manually. what I mean is,
    when the end user picks phase "Purchasing", you can change the where clause on the master block and execute the query to get the desired results
    e.g.
    v_cod varchar2(200) := 'STATUS_CODE in (select code from status where phase = ''Purchasing'')';
    begin
    set_block_property(requisition_blk,default_where,v_cod);
    execute_query;ofcourse you have to change "Purchasing" in the previous code to the item that holds the user inputs
    hope this is helpful
    Edited by: Mohammed H. on Sep 19, 2008 6:45 PM

  • How to query the master block based on one of the values in detail block

    Hi,
    In version 6i forms, I have a field in data block which is not set as a database item. I am using that field to store a value from detail block. If I want to query the form using that field (which represents one of the values from detail block), how do I do that? Any pointers?
    TIA,

    Do you want to query a master, which contains a specific detail? If so, here's an example how you could do it with a PRE-QUERY-trigger:
    DECLARE
      vcQuery VARCHAR2(4000);
    BEGIN
      IF :MASTERBLOCK.THE_DETAIL_SEARCH_ITEM IS NOT NULL THEN
        -- Build up an exists Sub-Query
        vcQuery:=' MASTERBLOCKID IN (SELECT FK_TO_MASTERBLOCK FROM DETAILTABLE WHERE DETAIL_COLUMN=''' || :MASTERBLOCK.THE_DETAIL_SEARCH_ITEM|| ''')';
      END IF;
      SET_BLOCK_PROPERTY('MASTERBLOCK', DEFAULT_WHERE, vcQuery);
    END;

Maybe you are looking for

  • "_unknown" user issue

    I recently bought a new mac (iMac 27") and used the migration assistant to move my profile from my old mac to the new one. However, prior to doing so, I created a couple of IDs one or two of which had admin access. After I then successfully migrated

  • NetscapeDispatchWnd: firefox.exe - Application Error

    Hello, My parents asked me if i could speed up their pc. Hence, i removed stuff like MSN (they don't use it) and i installed firefox. My own 3 pc's all run FF and never have any issues. But my parent's pc... Every time i close FF i get the following

  • FileDialog.SAVE: trap the "Save" button click event

    Hello All Can anyone help me with FileDialog.SAVE, as to how we could trap the Save button click event? Is it possible to actually trap that particular event, rather than just checking for FileDialog.getFile() == null -> which indicates that "Cancel"

  • Help!!! Can't access my icloud

    Im from the Philippines  and my uncle is from chicago he bought me a new ipad air.. When i opened it and start using it inoticed that he used his icloud acct. to make the ipad to work.. I was gonna delete his icloud acct. but it is requiring me his i

  • Automatic po from outline agreement

    Eventhough i have maintained outline agreement against material codes, as well as checked auto po and source in material master and auto po in vendor master, and the PR is even release. while running me59n it says, message no.ME261 ( No suitable purc