Home » Developer & Programmer » Forms » infinite loop caused by when-new-item-instance (forms6i)
infinite loop caused by when-new-item-instance [message #422786] Sat, 19 September 2009 03:26 Go to next message
Martin Eysackers
Messages: 80
Registered: October 2005
Location: Belgium
Member
Hi all,



I want to loop through my block to make a sum of a field always 100%

see attached fmb

create table shares 
(shares number)
/

insert into shares (shares) values (10);
/
insert into shares (shares) values (50);
/
commit;
/




when-new-item-instance is an block level :
(form has 1 block with one item and one summary item (calculated field)

--message(:col_right_type_shares.total_shares);
--message(:col_right_type_shares.total_shares);
--message(:system.last_record);
DECLARE
  lv_current_record   number;
  lv_cursor_item      varchar2(61);
BEGIN
   message('wvblock.looping ' || :wvblock.looping);
   IF nvl(:wvblock.looping, 0) = 0 THEN
--    lv_current_record := get_block_property(:system.trigger_block, current_record);
  --  lv_cursor_item := :system.cursor_item;
    :wvblock.looping := 1; 
    first_record;
          LOOP
              message(:system.last_record);
              message('record # ' || get_block_property(:system.trigger_block, current_record));
              synchronize;
              IF :system.last_record = 'TRUE' THEN
                   IF :shares.shares <> 100 - :shares.total_shares THEN
                          :shares.shares := :shares.shares + 100 - :shares.total_shares;                                       
                   END IF;
              END IF;
              next_record;
              exit when :system.last_record = 'TRUE';
          END LOOP;
              --go_item(lv_cursor_item);
              --go_record(lv_current_record);
       --       message(:wvblock.looping);
      
   END IF;
   :wvblock.looping := 0;
END;    



it loops through the block alright and changes the last record to make the total 100%

unfortunately it keps looping through my block infinitely
I used :wvblock.looping to prevent this but must be doing
something wrong


any ideas I am stuck



Kr
Martin
  • Attachment: shares.fmb
    (Size: 48.00KB, Downloaded 1102 times)

[Updated on: Sat, 19 September 2009 21:35]

Report message to a moderator

Re: infinite loop caused by when-new-item-instance [message #422823 is a reply to message #422786] Sat, 19 September 2009 21:36 Go to previous messageGo to next message
Martin Eysackers
Messages: 80
Registered: October 2005
Location: Belgium
Member
anyone any ideas ?
Re: infinite loop caused by when-new-item-instance [message #422840 is a reply to message #422786] Sun, 20 September 2009 08:52 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I don't think that WHEN-NEW-ITEM-INSTANCE block-level trigger is to be used; I'd rather try with WHEN-VALIDATE-ITEM trigger. Remove your trigger completely and put this code into the WHEN-VALIDATE-ITEM trigger:
if :shares.total_shares <= 100 then
   null;   -- i.e. don't do anything - summary item is < 100
else
   :shares.shares := :shares.shares + 100 - :shares.total_shares;
end if;

(Also, remove the unnecessary "wvblock" block).
Re: infinite loop caused by when-new-item-instance [message #422845 is a reply to message #422823] Sun, 20 September 2009 11:21 Go to previous messageGo to next message
Martin Eysackers
Messages: 80
Registered: October 2005
Location: Belgium
Member
That 's not what I want let's ssay you have these lines;

50
40
10


when line 2 is changed to 50
then the last record should also change
to have a total of 100
in this case it should change to 0


any ideas

kR
Martin
Re: infinite loop caused by when-new-item-instance [message #422997 is a reply to message #422845] Mon, 21 September 2009 12:22 Go to previous message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Well, that's something different and - at first sight - much too complicated. How would you determine which records to modify and how if there were
50
20
10
7
12
1
and someone modifies 20 to 30; what would you do in that case?
Previous Topic: FRM-40501 and ORA-02014 despite instead of trigger on view
Next Topic: How to open WordPerfect document in forms
Goto Forum:
  


Current Time: Fri Sep 20 09:22:13 CDT 2024