Home » Developer & Programmer » Forms » Delete_record in block. (Oracle Form 10g.)
Delete_record in block. [message #528757] Wed, 26 October 2011 22:31 Go to next message
dophuong_cs
Messages: 92
Registered: May 2011
Location: Viet Nam
Member

Hi all,
I have form same picture under, and i would delete record already checked on tabular when click button DELETE .
Please help me problem that.
Thanks.

[Updated on: Wed, 26 October 2011 22:35]

Report message to a moderator

Re: Delete_record in block. [message #528779 is a reply to message #528757] Thu, 27 October 2011 01:18 Go to previous messageGo to next message
Littlefoot
Messages: 21578
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Loop through all records on the form and perform DELETE_RECORD where the checkbox is checked.
Re: Delete_record in block. [message #528783 is a reply to message #528779] Thu, 27 October 2011 02:12 Go to previous messageGo to next message
dophuong_cs
Messages: 92
Registered: May 2011
Location: Viet Nam
Member

Declare
   al_buton Number;
   a        Varchar2(123) := Null;
Begin
   If :log_store.chk_check <> 'Y' Then
      set_alert_property('QMS$WARNING', alert_message_text, ' Choose record before delete! ' || chr(10) || ' Chon ban ghi truoc khi xoa');
      al_buton := show_alert('QMS$WARNING');
   End If;
   go_block('log_store');
   first_record;
   Loop
      If :log_store.chk_check = 'Y' Then
         delete_record;
      End If;
      If :system.last_record = 'TRUE' Then
         Exit;
      End If;
      next_record;
   End Loop;
   Commit;
   go_block('log_store');
   do_key('execute_query');
End;



I have code same above but if i choose all record in tabular then can not delete last_record.
How to delete last_record?
Please help me.
Re: Delete_record in block. [message #528794 is a reply to message #528783] Thu, 27 October 2011 03:38 Go to previous messageGo to next message
cookiemonster
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
That'll be because when you delete a record the cursor immediately moves to the next record.
So when you delete the record before last the cursor moves to the last record and :system.last_record is then true.
I suspect the code inside the loop should be:
  If :system.last_record = 'TRUE' THEN
    If :log_store.chk_check = 'Y' Then
      delete_record;
      Exit;
    End If;
  ELSE
    If :log_store.chk_check = 'Y' Then
      delete_record;
    ELSE
      next_record;
    End If;
  END IF;
icon2.gif  Re: Delete_record in block. [message #528804 is a reply to message #528794] Thu, 27 October 2011 04:18 Go to previous messageGo to next message
dophuong_cs
Messages: 92
Registered: May 2011
Location: Viet Nam
Member

thank you, but if i choose same picture under then when run form not succecss and i see form stop at line when run debug. example code under
If :log_store.chk_check = 'Y' Then
      delete_record;

how do i do?


[EDITED by LF: removed unnecessary quote of the whole previous message, as well as superfluous empty lines]

[Updated on: Sun, 19 February 2012 12:56] by Moderator

Report message to a moderator

Re: Delete_record in block. [message #528809 is a reply to message #528804] Thu, 27 October 2011 04:35 Go to previous messageGo to next message
cookiemonster
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
I put the exit in the wrong place.
  If :system.last_record = 'TRUE' THEN
    If :log_store.chk_check = 'Y' Then
      delete_record;
    End If;
    Exit;
  ELSE
    If :log_store.chk_check = 'Y' Then
      delete_record;
    ELSE
      next_record;
    End If;
  END IF;
Re: Delete_record in block. [message #678435 is a reply to message #528783] Tue, 03 December 2019 22:09 Go to previous messageGo to next message
chirag1890
Messages: 4
Registered: July 2012
Location: Malaysia
Junior Member
Begin

go_block('BP_ADVICE_PAYMENTS');
first_record;
Loop
If :BP_ADVICE_PAYMENTS.PAY != 'Y' Then
delete_record;
FIRST_RECORD;
End If;
If :system.last_record = 'TRUE' Then
Exit;
End If;
next_record;
End Loop;
Commit;
go_block('BP');
-- do_key('execute_query');
End;
Re: Delete_record in block. [message #678441 is a reply to message #678435] Wed, 04 December 2019 05:58 Go to previous messageGo to next message
cookiemonster
Messages: 13894
Registered: September 2008
Location: Rainy Manchester
Senior Member
1) This thread is 8 years old.
2) Code should be wrapped in [code] tags
3) You should also format your code.
4) Going to the first record every time you delete is inefficient
Re: Delete_record in block. [message #678481 is a reply to message #678441] Sun, 08 December 2019 13:51 Go to previous message
Littlefoot
Messages: 21578
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
5) Although commented, you don't need to do_key; just call execute_query
Previous Topic: FORMAT OF DATA IN FORMS 6i
Next Topic: How to enlarge an item within a region by clicking it
Goto Forum:
  


Current Time: Fri Aug 07 04:53:29 CDT 2020