4 Replies Latest reply: Aug 28, 2013 3:10 AM by sm*290887*m7 RSS

    Unable to delete two records in once in tabular form

    sm*290887*m7

      Hi all,

       

      I have a tabular form build, in there I have a delete item button where to delete those checked item from the tabular form.  If I checked for two records continuously from one after another, and press the delete item button, it is only delete the first record that I checked only. Whereas, if I selected two records where both of them is not one after another. Both records will be get deleted.

       

      begin

      GO_BLOCK('ACT_QT_TXN');

      FIRST_RECORD;

      LOOP

            IF :ACT_QT_TXN.CHECK_BOX256 = 1 THEN

        

               delete_record;

               COMMIT_FORM;

         

            END IF;

       

           NEXT_RECORD;

        

           IF (:System.Last_Record = 'TRUE')  and :ACT_QT_TXN.CHECK_BOX256 = 1 THEN

                     DELETE_RECORD;

                     COMMIT_FORM;

                     EXIT;

           ELSE

                  IF  (:System.Last_Record = 'TRUE') THEN

                          EXIT;

                  END IF;

           END IF;

        

       

      END LOOP;

      FIRST_RECORD;

      execute_query(no_validate);

      end;

       

       

      Anything wrong with my script above ? Please help me. Thanks/

       

      Regards,

      Lim

        • 1. Re: Unable to delete two records in once in tabular form
          Soofi

           

          Hi SM,

          Write the Query Changing the name of your Check_Box in the Delete Button -When Button Pressed Trigger....

           

          FIRST_RECORD;

          DECLARE

          BEGIN
          LOOP

          if :CHECK_BOX  = 'Y' then

          delete_record;
          end if;

                EXIT WHEN :SYSTEM.LAST_RECORD = 'TRUE';

            NEXT_RECORD;

             END LOOP;

          COMMIT;

          FIRST_RECORD;

          execute_query(no_validate);

          END;

           

           

          This will work for you.

           

          Regards,

          Soofi.

          • 2. Re: Unable to delete two records in once in tabular form
            Bhushan53

            The issue is with Commit_form after every single deletion. What Soofi has given is slick, but i would like it this way -

             

            FIRST_RECORD;

            DECLARE

            BEGIN
            LOOP

            EXIT WHEN :SYSTEM.RECORD_STATUS = 'NEW';

            if :CHECK_BOX  = 'Y' then

            delete_record;
            end if;

             

              NEXT_RECORD;

               END LOOP;

            COMMIT;

            FIRST_RECORD;

            execute_query(no_validate);

            END;

             

            Regards

            Bhushan

            • 3. Re: Unable to delete two records in once in tabular form
              sm*290887*m7

              Hi guys,

               

              I've tried for both script, again only the first checked record is being deleted.  Let me illustrated the scenario.

               

              checked two records continue in tabular form.

               

              Record 1  ( checked )

              Record 2  ( checked )

               

              When click on the delete item button, the first record 1 is being deleted from the screen once pressed. The deleted record is disappear right away. Now the cursor is jump to the record 2 straight. After that, the script reach NEXT_RECORD, the third record is not checked hence it was not deleted and same goes to the rest till the end of form.  Now problem, is when delete on the first record 1, the record get deleted and screen get refresh and then the cursor is lying at the record 2, then next record will jump to record 3 but this record is not checked.

               

              If the screen not get refresh and only refresh at the end of the loop then it will solve my problem. Where else went wrong ?

               

              Hope my explanation is clear. 

              • 4. Re: Unable to delete two records in once in tabular form
                sm*290887*m7

                Hi guys,

                 

                I got it right. I have one key-commit trigger in the data block area, which issue the commit form and execute query when form changed. I removed that and now it is working fine.

                 

                Thanks for your reply....