Home » Developer & Programmer » Forms » loop not working properly
loop not working properly [message #478661] Mon, 11 October 2010 10:05 Go to next message
simcky
Messages: 38
Registered: July 2009
Member
Hi guys

here i m giving the code

DECLARE
TYPE SUBNO_TABLE_TYPE IS TABLE OF
TRANS_DEICMAIN1.SUBNO%TYPE
INDEX BY BINARY_INTEGER;
SUBNO_TABLE SUBNO_TABLE_TYPE;
K NUMBER := 1;
S NUMBER := 1;
BEGIN
GO_BLOCK('BLOCK7');

FIRST_RECORD;
LOOP
IF :BLOCK7.CHECK1 = 'Y'
THEN
SUBNO_TABLE(K) := :BLOCK7.SUBNO;
END LOOP;
K := K+1;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
END LOOP;
FIRST_RECORD;
K := 1;
GO_BLOCK('BLOCK2');
FIRST_RECORD;
LOOP
IF
:BLOCK2.SUBNO = SUBNO_TABLE(K)
THEN
K := K+1;
INSERT INTO BLOCK2 VALUES(:BLOCK2.SUBNO,:BLOCK2.NAME);
END IF;
EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
NEXT_RECORD;
END LOOP;
END;

HERE CHECK1 IS A CHECKBOX.
WHEN I AM USING THIS CODE ONLY ONE RECORD IS SAVED AT A TIME INSTEAD OF SAVING ALL RECORDS.COULD SOMEONE please HELP ME TO REMOVE THE BUG
Re: loop not working properly [message #478671 is a reply to message #478661] Mon, 11 October 2010 15:37 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Please, format your code and post it again, using [code] tags in order to preserve formatting so that we could see what you are doing. The way it is now, it is difficult to read it. I wanted to format it for you, but OraFAQ's code formatter complains about some errors (which I'm not willing to investigate at the moment; maybe there aren't any, but formatter doesn't understand Forms' PL/SQL).
Re: loop not working properly [message #478699 is a reply to message #478671] Tue, 12 October 2010 01:46 Go to previous message
deepakmannazhi
Messages: 137
Registered: February 2010
Location: Dubai, UAE
Senior Member

Dear Simcky,
Please Check the code below,

 DECLARE
   TYPE subno_table_type IS TABLE OF trans_deicmain1.subno%TYPE
      INDEX BY BINARY_INTEGER;

   subno_table   subno_table_type;
   k             NUMBER           := 1;
   s             NUMBER           := 1;
BEGIN
   GO_BLOCK ('BLOCK7');
   FIRST_RECORD;

   LOOP
      IF :block7.check1 = 'Y'
      THEN
         subno_table (k) := :block7.subno;
      END IF;******************************
The problem may be here, here you put END LOOP instead of END IF;

      k := k + 1;
      EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
      NEXT_RECORD;
   END LOOP;

   FIRST_RECORD;
   k := 1;
   GO_BLOCK ('BLOCK2');
   FIRST_RECORD;

   LOOP
      IF :block2.subno = subno_table (k)
      THEN
         k := k + 1;

         INSERT INTO block2
              VALUES (:block2.subno, :block2.NAME);
      END IF;

      EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';
      NEXT_RECORD;
   END LOOP;
END;


Regards
Deepak
Previous Topic: Deleting a uploaded file from server
Next Topic: Compilation error
Goto Forum:
  


Current Time: Fri Sep 20 04:45:47 CDT 2024