Home » Developer & Programmer » Forms » multi record block loop problem
multi record block loop problem [message #157027] Mon, 30 January 2006 15:31 Go to next message
vinodkumarn
Messages: 60
Registered: March 2005
Member
I have a multi record block in the top which is parent
i have multi record block below which is detail

now i want to copy the an item value from parent to detail. The loop should go to second record in the parent (it should start from 2nd record) and assign and item value to its detail and then again it should now go to the 3rd parent and assign the item value to its detail and so on...

i have the following code, problem here is it assigns the item value to the 2nd detail from 2nd parent but the loop is not going to the 3rd parent and is not assigning to the 3rd detail

can anyone tell me what is the problem here

BEGIN
GO_BLOCK('PARENT');
next_record;
LOOP
GO_BLOCK('DETAIL');
LOOP
:detail.code := :parent.code;
IF :system.last_record = 'TRUE' THEN
EXIT;
End If;
END LOOP;
IF :system.last_record = 'TRUE' THEN
EXIT;
END IF;
NEXT_RECORD;
END LOOP;
END;
Re: multi record block loop problem [message #157031 is a reply to message #157027] Mon, 30 January 2006 16:15 Go to previous messageGo to next message
vinodkumarn
Messages: 60
Registered: March 2005
Member
thanks i solved the problem, code is

BEGIN
GO_BLOCK('PARENT');
next_record;
LOOP
:detail.code := :parent.code;
IF :system.last_record = 'TRUE' THEN
EXIT;
END IF;
NEXT_RECORD;
END LOOP;
END;
Re: multi record block loop problem [message #157639 is a reply to message #157031] Fri, 03 February 2006 10:54 Go to previous messageGo to next message
RJ.Zijlstra
Messages: 104
Registered: December 2005
Location: Netherlands - IJmuiden
Senior Member
Just curious.

Why are you doing this? If you use the 'relations' option (in the navigator under your master block) this 'synchronizing' will be done automatically by Forms.

Re: multi record block loop problem [message #157684 is a reply to message #157027] Fri, 03 February 2006 19:01 Go to previous message
M0nst3r
Messages: 38
Registered: February 2006
Location: Wherever the Money Is
Member
You may want to reconsider your design as RJ.Zijlstra suggested.

Your first attempt was less flawed than your second attempt. Two potential problems with your revised code:
1. GO_BLOCK() sends the cursor to the current record in the target block, not the first record.
2. Your code will only work on a 1:1 FK relationship.

Here's the solution according to your requirements:
BEGIN
  GO_BLOCK('PARENT');
  FIRST_RECORD;
  IF (:SYSTEM.LAST_RECORD = 'TRUE') THEN
    EXIT;
  END IF;
  GO_RECORD(2);
  <<PARENT_LOOP>>
  LOOP
    GO_BLOCK('DETAIL');
    <<DETAIL_LOOP>>
    LOOP
      :detail.code := :parent.code;
      IF (:SYSTEM.LAST_RECORD = 'TRUE') THEN
        EXIT DETAIL_LOOP;
      END IF;
    END LOOP;
    GO_BLOCK('PARENT');
    IF (:SYSTEM.LAST_RECORD = 'TRUE') THEN
      EXIT PARENT_LOOP;
    END IF;
    NEXT_RECORD;
  END LOOP;
END;

Upd-mod: Add code tags.

[Updated on: Wed, 08 February 2006 23:53] by Moderator

Report message to a moderator

Previous Topic: Steps for applying patch
Next Topic: Screen asks do you want to commit records?
Goto Forum:
  


Current Time: Fri Sep 20 03:59:05 CDT 2024