|
|
Re: Delete_record in block. [message #528783 is a reply to message #528779] |
Thu, 27 October 2011 02:12 |
|
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 |
cookiemonster
Messages: 13963 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;
|
|
|
Re: Delete_record in block. [message #528804 is a reply to message #528794] |
Thu, 27 October 2011 04:18 |
|
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 |
cookiemonster
Messages: 13963 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 #678441 is a reply to message #678435] |
Wed, 04 December 2019 05:58 |
cookiemonster
Messages: 13963 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
|
|
|
|