2 Replies Latest reply: May 3, 2013 9:32 AM by NuhaArif RSS

    Update using check box hangs

    NuhaArif
      have a table where i need to update one field values based on another field of the same table , simply as it is.I have done this using one select all check box , on clicking that all check boxes of item_trans table will get selected , then i will un select some of check box and then using one button, i will update the value of the fields which are checked only.
      I have put the sample code but when i am updating its taking long time and hanging.I am also attaching the form based on the test case provided.

      --tables with insert statement
      create table item_trans (trans_item varchar2(12),trans_qty number,trans_act_qty number)
      
      insert into item_trans(TRANS_ITEM,TRANS_QTY,TRANS_ACT_QTY) VALUES ('TREE1',40,NULL);
      
      insert into item_trans(TRANS_ITEM,TRANS_QTY,TRANS_ACT_QTY) VALUES ('TREE2',20,NULL);
      
      insert into item_trans(TRANS_ITEM,TRANS_QTY,TRANS_ACT_QTY) VALUES ('TREE3',20,NULL);
      
      
      --i want to set the value of trans_Act_qty as trans_qty
      
      --i create one dummy or test block to keep the select all check box. for that table test script is
      
      CREATE TABLE TEST
      (
        C  VARCHAR2(2000 BYTE),
        B  NUMBER,
        A  NUMBER
      );
      
      insert into test (C,B,A) values ('A',1,1);
      
      --code written in select all check box which is created on test.block.
      
      BEGIN
           GO_BLOCK('item_trans');
           FIRST_RECORD;
           LOOP
                :M_END_YN := :M_END_ALL;
                IF :SYSTEM.LAST_RECORD = 'TRUE' THEN
                      :M_END_YN := :M_END_ALL;
                      EXIT;
                ELSE
                     NEXT_RECORD;
                END IF;
           END LOOP;
           FIRST_RECORD;
      END;
      
      
      --code written in M_END_YN ( actual check boxes where i will uncheck).
      
      IF :M_END_YN = 'N' THEN
           :M_END_ALL := 'N';
      END IF;
      
      --code written on button to update those values which are checked.
      
      
      
      BEGIN
         GO_BLOCK('item_trans');   
         FIRST_RECORD;   
         LOOP      
            IF :M_END_YN = 'Y' THEN 
               :TRANS_ACT_QTY := :TRANS_QTY    ; 
            ELSE
                  NEXT_RECORD;
            END IF ;      
            IF :SYSTEM.LAST_RECORD = 'TRUE' THEN 
                   IF :M_END_YN = 'Y' THEN 
                  :TRANS_ACT_QTY := :TRANS_QTY  ;      
                END IF;
              EXIT;      
            END IF; 
         END LOOP;
          DO_KEY('COMMIT_FORM');  
       
      END;
        • 1. Re: Update using check box hangs
          InoL
          This is an infinite loop:
             FIRST_RECORD;   
             LOOP      
                IF :M_END_YN = 'Y' THEN 
                   :TRANS_ACT_QTY := :TRANS_QTY    ;   -- => you are not doing a NEXT_RECORD here, so you are hanging in this record
                ELSE
                      NEXT_RECORD;
                END IF ;      
                IF :SYSTEM.LAST_RECORD = 'TRUE' THEN 
                  (...)
          • 2. Re: Update using check box hangs
            NuhaArif
            thanks for the reply, can i use the below code.
            FIRST_RECORD;   
               LOOP      
                  IF :M_END_YN = 'Y' THEN 
                     :TRANS_ACT_QTY := :TRANS_QTY    ;   -- => you are not doing a NEXT_RECORD here, so you are hanging in this record
                              NEXT_RECORD;
                  END IF ;      
                  IF :SYSTEM.LAST_RECORD = 'TRUE' THEN 
                    (...)
            
            or 
            FIRST_RECORD
            WHILE :M_END_YN='Y' LOOP
            :TRANS_ACT_QTY := :TRANS_QTY;
            NEXT_RECORD;
            EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE'