7 Replies Latest reply: Apr 9, 2013 11:58 PM by XeM RSS

    delete_record

    Goldray
      Hi,
      I want to delete a record from my form, but the problem that the record is deleted only from the form and in the DB still existing.

      note: The data block is based.

      code:
      delete_record;
      commit;

      Edited by: 979155 on 9 avr. 2013 09:33
        • 1. Re: delete_record
          MLBrown
          That is the right commands to delete a record and commit, but are you on that block when you execute the command?

          If the name of your block is MAIN_RECORD, then try:
          go_block('MAIN_RECORD');
          delete_record;
          commit;
          • 2. Re: delete_record
            Goldray
            Same problem persists !!
            • 3. Re: delete_record
              MLBrown
              Hmmm... Do you have ON-ERROR or ON-MESSAGE triggers in that form that might be preventing an error from displaying?

              If the property pallette shows the "Database Data Block" set to "Yes" and you delete te record then it should delete it from the form and the database, then on commit make that permanent. Is the record in question, being deleted from the form? Maybe a different record in that block is being deleted.
              • 4. Re: delete_record
                O.Developer
                Check the particular table (level) having any trigger on delete- which may prevent your form


                -------To give more idea,

                give your exact example...

                979155 wrote:
                Same problem persists !!
                • 5. Re: delete_record
                  Goldray
                  I think the problem due to use of many stacked Canves in the same form !!

                  code:
                  when-button-pressed trigger
                  declare
                       i number;
                  v_nb number;
                  begin

                       if :block.key IS NOT NULL THEN
                       select count(*) into v_nb from emp where no=:block.key;
                       
                       if v_nb =0 then
                       i:= show_alert('supp');
                       if i=alert_button1 then
                       delete_record;
                            commit;
                  --     message('record delete');
                       end if;
                       else
                            i:=show_alert('impo');
                       end if;
                  --     go_item('search.rch');
                       end if;

                  end;
                  • 6. Re: delete_record
                    user346369
                        if  :block.key IS NOT NULL THEN
                          select count(*) into v_nb from emp where no=:block.key;
                          if v_nb =0 then
                            i:= show_alert('supp');
                            if i=alert_button1 then
                                 delete_record;
                                 commit;
                                --message('record delete');
                            end if;
                    So let's see....
                    Your delete_record and commit are nested three levels deep in IF statements. To actually delete a record, you need
                    1. there MUST be NO rows where emp.no is equal to the value in :Block.key
                    2. then you Show_alert.
                    3. IF you click on the first button of the alert,
                    4. you then delete a record in whatever block the cursor is in.

                    But you have commented out the message, so you have no idea that the commit is actually being executed. I am not surprised nothing is being deleted.
                    • 7. Re: delete_record
                      XeM
                      Hi,

                      Check your Pre-delete, on-delete and Key-delete triggers . some times this happens due to when you set a trigger to null specially triggers associated with delete.