Fill a multi record block with a for-loop

Hi
I've got a simple question but I couldn't find a solution yet.
I have a multi record block and behind this i wrote a post-query-trigger with a cursor and a for-loop. Now I try to show each record of the for-loop in the multi record block. The loop works correctly, but the problem is that I only see the last found record of the loop in the first multi record and I'm not able to go to the next multi record when the loop finds more then one record.
I tried to use NEXT_RECORD but then I got the error message "100500: non-ORACLE exception".
May someone help me? Thanks a lot!

What exactly are you trying to do? If you are simply trying to display the result of a query in a Multi-Record Block (MRB), I would recommend basing your block on the query (From Clause Query) or if you are simply displaying the contents of a table or a view in the block, base your MRB on the table or view and let Forms handle displaying the records.
The Post-Query (PQ) trigger will execute for each record displayed in the MRB, which I'm sure is not what you intended. Since the trigger fires for each record, your loop is essentially assigning the value of each row in the cursor to the same row in the MRB.
Hope this helps.
Craig...

Similar Messages

  • Moving cursor on  multi-record block with pjc components

    Hi, this thread question is updated to a more specific and correct one in the new thread:
    Need help on using navigation function in when-custom-item-event trigger
    Please, follow there...
    I have a pjc on a multi-record block. When I activate the pjc the forms cursor does not navigate to the item.
    The when-custom-item-event is activated. My question is how do I move the cursor to the current record?
    Best regards,
    Constantin
    Edited by: ConstGl on Jan 11, 2011 5:47 AM

    +"... When I activate the pjc the forms cursor does not navigate to the item..."+
    Sorry, but this is not clear for me.
    Francois

  • Multi-record block (how do I loop through the block)

    I created a two canvas form. On the first canvas, the user enters data and selects 1 - 30
    reports that they want to run. When they click on <NEXT> button, I create a multi-record
    control block and display each record on the second screen using
    go_block;
    clear_block;
    move data;
    create_record;
    The user then selects on the second canvas which reports to run now and which to run later via
    a LOV. When they press the <RUN> button, I want to start at the first record and either run the
    report or schedule it. Then I want to move onto the second and the third until all selected reports
    have been handled. I know I should use a loop but can't seem to make it work.
    So my question is, How do I loop through the records in a multi-record control block, pass the information
    for that one record to a parameter form and then execute the request? Each control block record contains
    10 parameter fields.
    Thanks.
    Bob

    go_record(1);
    << do your processing >> -- This is executed only for the first record.
    if :system.last_record = 'TRUE' then -- If the 1st record is also the last record.
    RETURN;
    end if;
    LOOP
    next_record;
    << do your processing >>
    if :system.last_record = 'TRUE' then
    EXIT;
    end if;
    END LOOP;
    I created a two canvas form. On the first canvas, the user enters data and selects 1 - 30
    reports that they want to run. When they click on <NEXT> button, I create a multi-record
    control block and display each record on the second screen using
    go_block;
    clear_block;
    move data;
    create_record;
    The user then selects on the second canvas which reports to run now and which to run later via
    a LOV. When they press the <RUN> button, I want to start at the first record and either run the
    report or schedule it. Then I want to move onto the second and the third until all selected reports
    have been handled. I know I should use a loop but can't seem to make it work.
    So my question is, How do I loop through the records in a multi-record control block, pass the information
    for that one record to a parameter form and then execute the request? Each control block record contains
    10 parameter fields.
    Thanks.
    Bob

  • How to do validation on multi record block at run time...

    Dear Friends,
    I have to do validation at run time on multi record block.
    If user tries to enter and save two or more records in same multi record block with same data at run time, it should not allow it and display a message like, " error : Records are having same(duplicate) values. "
    I already did validation with the data coming from database table using cursor. But confused about how to do at run time(on one screen only) ??
    Please, give details about how to check duplicate records on form block before saving it to the table ????
    Regarding details would be greatly helpful.
    thanks,

    Hi...Pankaj
    thanx for your reply..
    I already did validation for the data coming from table....
    but I need to do it on form only...at run time...
    exa...
    In one multi record block
    record no : column 1 : column 2 : column 3
    1 abc 123 hi
    2 abc 123 hi
    so it should check on the form itself, here I m not getting data from table...I am just
    navigating from first record to second using down arrow.
    so, may be 2 possibilities.
    1) when user navigates using tab to third record, it should say like two duplicate records.(may be like when validate record or item)
    2) or when user tries to save, it should say two duplicate records.
    so, everyting should take place on form screen only.....
    waiting for your reply,
    thanx...

  • Check duplicate data entry in multi record block,which is a mandatory field

    Dear all,
    I have a situation where i have to check duplicate data entry(on a particular field,which is a mandatory field,i.e. it cannot be skipped by user without entering value) while data key-in in a Multi Record block.
    As for reference I have used a logic,such as
    1>In a When-Validate-Record trigger of that block I am assigning the value of that current item in Table type variable(collection type)
    as this trigger fire every time as soon as i leave that record,so its assigning the value of that current time.And this process continues
    then
    2>In a When-Validate-Item trigger of that corresponding item(i.e. the trigger is at item level) has been written,where it compares the value of that current item and the value stored in Table type variable(collection type) of When-Validate-Record trigger.If the current item value is matched with any value stored in Table type variable I am showing a message of ('Duplicate Record') following by raise_form_trigger failure
    This code is working fine for checking duplicate value of that multi record field
    The problem is that,if user enter the value in that field,and then goes to next field,enter value to that field and then press 'Enter Query 'icon,the bolth Validate trigger fires.As result first when-validate record fires,which stores that value,and then when-validate-item fires,as a result it shows duplicate record message
    Please give me a meaningful logic or code for solving this problem
    Any other logic to solve this problem is also welcome

    @Ammad Ahmed
    first of all thanks .your logic worked,but still i have some little bit of problem,
    now the requirement is a master detail form where both master and detail is multirecord ,where detail cannot have duplicate record,
    such as..........
    MASTER:--
    A code
    A1
    A2
    DETAIL:--
    D code
    d1
    d2 <-valid as for master A1 , detail d1 ,d2 are not duplicate
    d2 <--invalid as as for master A1 , detail d2 ,d2 are duplicate
    validation rule:  A Code –D Code combination is unique. The system will stop users from entering duplicate D Code for a A Code. Appropriate error message will be displayed.*
    actually i am facing a typical problem,the same logic i have been applied in detail section ,its working fine when i am inserting new records.problem starts when i query,after query in ' a ' field say 2 records (i.e. which has been earlier saved) has been pasted,now if i insert a new record with the value exactly same with the already present value in the screen(i.e. value populated after query) its not showing duplicate.................could u tell me the reason?and help me out...............its urgent plzzzzzzzzz
    Edited by: sushovan on Nov 22, 2010 4:34 AM
    Edited by: sushovan on Nov 22, 2010 4:36 AM
    Edited by: sushovan on Nov 22, 2010 8:58 AM

  • Check Duplicate data during data key-in Multi Record Block

    Dear all,
    I have a situation where i have to check duplicate data entry(on a particular field,which is a mandatory field,i.e. it cannot be skipped by user without entering value) while data key-in in a Multi Record block.
    As for reference I have used a logic,such as
    1>In a When-Validate-Record trigger of that block I am assigning the value of that current item in Table type variable(collection type)
    as this trigger fire every time as soon as i leave that record,so its assigning the value of that current time.And this process continues
    then
    2>In a When-Validate-Item trigger of that corresponding item(i.e. the trigger is at item level) has been written,where it compares the value of that current item and the value stored in Table type variable(collection type) of When-Validate-Record trigger.If the current item value is matched with any value stored in Table type variable I am showing a message of ('Duplicate Record') following by raise_form_trigger failure
    This code is working fine for checking duplicate value of that multi record field
    The problem here is that suppose if usee gets a message of ('Duplicate Record') and after that without saving the values if user try to query of that block then also when validate item fired where as I am expecting ORACLE default alert message('Do You want to save?'),I want to restrict this When-Validate Item fire during query time..........................while user try to query.
    Please give me a meaningful logic or code for solving this problem
    Any other logic to solve this problem is also welcome

    When-Validate-Record trigger
    When-Validate-Item triggerThat smells like Oracle Forms...
    And the Oracle Forms forum is over here: Forms

  • Multi Record Block Problem

    Hi,
    I have a multi record block with two fields NAME and DATE. On clicking the Save Button a procedure (PROC_BEFORE_SAVE) is called which loops through this block, and deletes empty records.
    PROC_BEFORE_SAVE
    LOOP
         IF :TI_NAME IS NULL THEN
              DELETE_RECORD;
         END IF;
         NEXT_RECORD;
         EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
    END LOOP;
    The proc fails and throws error (Oracle Error Unable to Update Records) only for the case that the first few records are null. Sample data given below.
    Name  -  Date
    NULL  -  NULL
    NULL  -  NULL
    NULL  -  NULL
    AJ  -  10/02/2005
    JA  -  12/12/2004
    AJV  -  12/12/2002
    This happens because it tries to update the NOT NULL field NAME as NULL.
    Could somebody please tell me why this is happening? Is there something wrong with the procedure?
    I am using Oracle Forms 6.0.8.8.0 in Windows 2000 Professional edition.
    Any help would be greatly appreciated.
    Thanks,
    Anoop

    Hi,
    Thanks for the reply. But CLEAR_RECORD also doesn't seem to work.
    Thanks,
    Anoop

  • Disabling a button in a multi record block

    Hi everyone,
    I have a multi record block with a button on each record, I have to be able to disable a button at runtime (following some conditions).
    the SET_ITEM_INSTANCE_PROPERTY (item, record, enabled, property_false) does not work !
    Any idea on how can I do it ?
    Thanks for any help.

    I don't think "enabled" is a valid property for SET_ITEM_INSTANCE_PROPERTY. You were probably thinking of SET_ITEM_PROPERTY but this won't work for you at the record level.
    The only thing I can think of right off hand is to set the visual attribute using SET_ITEM_INSTANCE_PROPERTY to make each button look enabled or disabled. You could define 2 visual attributes, say something like VA_BUTTON_ENABLE and VA_BUTTON_DISABLE.
    If you want the button to look enabled then:
    SET_ITEM_INSTANCE_PROPERTY(item, record, visual_attribute, 'VA_BUTTON_ENABLED'');
    If you want the button to look disabled then:
    SET_ITEM_INSTANCE_PROPERTY(item, record, visual_attribute, 'VA_BUTTON_DISABLED');
    Then, in your WHEN-BUTTON-PRESSED trigger, look at the visual attribute for that record using the GET_ITEM_INSTANCE_PROPERTY, and if the visual attribute is VA_BUTTON_ENABLED then execute your button code otherwise don't do anything.
    Give it a try and see if that works for you.
    Hope it helps.
    Travis

  • Get the first item value of previous record in a multi record block

    Hai,
    I have a multi record block with four items.I should get the first item value of the previous record so that I can increment its value in the current record.
    Thanks.........

    If you want a distinct value in each row or to be able to retrieve the records in the same order they were written then you should use a sequence.
    If you want to retrieve the records in the same order they were created in the block then you will need a diffferent solution to the one you outline here since a user could enter a new record between two others.
    I posted this a while back in response to someone who was using a sort_key item and resetting it for each row when a new record was inserted:
    If you make the sort_key bigger then you have much more room to insert new rows in between existing rows without having to reset all the sort_keys.
    Eg. you have rows with sort_keys of 129282000000000000 and 129283000000000000 (you can have more zeros if you want) and you want to insert a row in between. if you're using oracle forms then the user would have to click on the first of these rows and then do 'insert'. in your insert process you would store the sort keys of the current record and the one below, create a blank record in between and set the sort_key of that record to the average of the other two. you will be able to insert many new rows in between the original 2 before running out of space in the sort_key field.
    the method above is not sufficient, there are some other cases to consider:
    1) when the user is on the last record of the block then you will just create a new record with sort_key set to a greater number than the row before. you can have the sort_key defined as number(38) and to safely allow you to enter 1000 rows each new row would normally be 10E33 greater than the previous one.
    2) when the user is entering the first record then just set the sort_key to 10E33.
    3) on the off-chance that you do insert a great number of records and cannot insert another in between then you would need to alert the user, process the records so that the sort_keys are evenly spaced and requery the block. this processing could be scheduled nightly to make this eventuality even less likely.
    4) make sure the user cannot run the default 'clear_record' procedure. this would break my method as well as yours!
    James.

  • Get next value in a Multi Record Block

    Hi,
    I've a Multi Record block with 2 items like below.
    pos width
    1 7
    8 5
    13 5
    18 2
    ie pos in next item is sum of pos and width of previous item.I've already implemented this.
    The problem is if the user changes width in a particular record,I want to change next records pos automatically.
    To achieve this,I wrote a when-new-record -instance-trigger as follws:
    if :system.cursor_record=1 then
    :pos:=1;
    elsif :system.record_status='changed' then
    :pos:=:pos+:width;
    end if;
    but even Though I change column width of block,:system.record_status still remain 'INSERT'.
    Pls can u pls tell me how can I acheive this?
    Prashanth Deshmukh

    You cannot use Record Status like that.
    You need to create a procedure that loops through your entire block, keeping track of the pos and width of the prior record to calculate the new pos of each record.
    Your procedure would need to do something like this:
    Declare
        v_Pos  pls_integer := 1;
    Begin
      Go_block('B1');
      First_Record;
      Loop
        Exit when :System.record_status='NEW';
        :B1.pos := v_Pos;
        v_Pos := v_Pos + :B1.width;
        Exit when :System.last_record = 'TRUE';
        Next_Record;
      End Loop;
      First_Record;
    End;

  • No base table multi record block...updation

    hello all,
    i have a multi record block with two fields order & datetime to capture the time of the order. but this block is not based on any table. and i want to update another table with the datetime based on the order captured.
    how to do that...? there may be n number of records coming into the block at a time.
    thx in adv.
    Kris

    the best way is make it as a database block .and palace your insert statement in pre-insert trigger when you are inserting the record and place your update trigger in pre-update trigger u can also place your insert and update statement in back end, "i prefer the backend triggers").I think this is the best way because if you are using the go_block and next_record, that may take lots of time time to traverse record by record.
    regards
    mathew

  • Image item in multi-record block - PLEASE SOMEONE HELP !

    Hello everyone.
    I have a multi-record block with an image item that is not in teh table, is populated in the post-query trigger with a read_image_item, from a gif file. This block is child of another block. The problem is that the first records of the block, the ones that fit on the screen, are not showing the image properly, the image appears grey, distorted. In reality, the image dont adjust to the size of the item, as it is especified in the properties. When i scroll down, the rest of records show the image perfect, but this ones still are distorted.
    Forms is 6.0.8.22.1, over oracle 9i. Thank you all in advance.

    hello
    just me what is datatype of ur image record ?

  • Image item in multi-record block

    Hello everyone.
    I have a multi-record block with an image item that is not in teh table, is populated in the post-query trigger with a read_image_item, from a gif file. This block is child of another block. The problem is that the first records of the block, the ones that fit on the screen, are not showing the image properly, the image appears grey, distorted. When i scroll down, the rest of records show the image perfect, but this ones still are distorted.
    Forms is 6.0.8.22.1, over oracle 9i. Thank you all in advance.

    hello
    just me what is datatype of ur image record ?

  • How to call a report with a bind variable from a multi-record block

    Hi,
    I have created a report using the BI Publisher functionality. I did all the integration, created the SQL Query and uploaded the template. Up till here everythings fine!
    My SQL Query has 2 bind variables.
    I will call my report from a multi record block, at the end of each record an icon is shown which the user can click to open the report.
    I created a column link for this item (PRINT_REPORT=Inschrijvingsformulier) but I do not manage to pass the parameters to my report. The parameters I want to pass are 2 columns in this Multi Record block.
    I created 2 hidden fields on the page P9_PARAMETER1, P9_PARAMETER2 with the same names as my bind variables and fill this in with the values #PARAMETER1#, #PARAMETER2# from the multi record block.
    It seems it does not work as my report stays empty. (also XML file stays empty).
    Am I trying the wrong way?
    Thanks for any advice,
    Kris

    hi khadeer,
         create one report program and write the required code,and call this function module 'SSF_FUNCTION_MODULE_NAME' and give your smartform name  and also when u activate ur smart form u will get one function module call that function module also and specify any tables used...
    i think this solves ur problem...
    any queries revert back..
    pls reward points if helpful,
    shylaja

  • Cursor Jumping to last record when query mode for Multi-record block.

    I have a multi-record block. the seq field has this validation to check that there should not be a gap
    in sequence for S_type and cer_dl field.The program unit is as below.
    PROCEDURE seq_validation IS
    --Validation to check that there is no gaps in sequence for S_TYPE and cer_dl fields
    l_value_to_check varchar2(100);
    l_seq_found number;
    l_curr_sequence number;
    l_new_value varchar2(100);
    l_found boolean:=FALSE;
    l_new_set boolean := FALSE; --s_type and cer_dl are different from previous set.
    begin
    if trim(:b1.s_type) is not null
    or trim(:b1.cer_dl) is not null
    then
    -- Program continues here only if all the items are not null
    -- Get information from record that needs to be validated
    l_value_to_check := trim(:b1.s_type) || ':'|| trim(:b1.cer_dl) ;
    l_curr_sequence := :sequence;
    if :SYSTEM.CURSOR_RECORD = '1' then
    ---to check sequence is entered as 1 in the first record
    message('Error:Sequence should start with 1');
    raise form_trigger_failure;
    end if;
    go_item('b1.XYZ');
    else
    FIRST_RECORD;
    while :SYSTEM.LAST_RECORD != 'TRUE'
    loop
    l_found := FALSE;
    l_new_value := trim(:b1.S_type) || ':'|| trim(:cer_dl) ;
    if l_new_value = l_value_to_check then --
    l_new_set:= FALSE;
    l_seq_found := :seq;
    if l_seq_found >= l_curr_sequence then
    go_item('b1.seq');
    l_new_set := FALSE;
    elsif l_seq_found < l_curr_sequence - 1 then
    go_item('b1.sequence');
    l_found := FALSE;
    elsif l_seq_found = l_curr_sequence - 1 then
    l_found:= TRUE;
    go_item('b1.xyz); --go to next item
    end if;
    else
    l_new_set := TRUE;
    end if;
    NEXT_RECORD;
    end loop;
    if l_new_set then
    go_item('b1.xyz'); -- go to next item
    else
    if not l_found then
    message('Error:Sequence should be in order.');
    go_item('b1.seq');
    raise form_trigger_failure;
    end if;
    end if;
    go_item('b1.xyz'); ---go to next item
    end if;
    end if;
    end;     
    In the insert mode its working fine(unless you gurus feel to change to make it more perfect.
    When I say enter-query and put 'IAS' in the s_type field and then do a execute query it brings all the records of 'IAS'.
    Now as I want to update the records, and when I navigate across field(s_type,cer_dl,Seq,xyz) using tab and move the cursor down on second
    record(IAS N 2 N), what happens is when I navigate to sequence field the cursor jumps to LAST RECORD( IAS Y 3 N ) of LAST field XYZ.
    I am putting the sample record
    s_type cer_dl seq xyz
    IAS N 1 N
    IAS N 2 N
    IAS N 3 N
    IAS N 4 N
    IAS Y 1 N
    IAS Y 2 N
    IAS Y 3 N
    The cursor moves to last record --IAS -Y -3-N when I tab across the second record.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    When I say enter-query and put 'IAS' in the s_type field...For your validation to work you must not allow users to enter records in the middle of a block, clear records from the block or query specific records. If you allow the users to enter a query then you are allowing 2 of the rules to be broken.

Maybe you are looking for