Home » Developer & Programmer » Forms » Delete Multiple Records (Windows Oracle Developer 6i.)
Delete Multiple Records [message #606446] Fri, 24 January 2014 00:21 Go to next message
whmemon
Messages: 26
Registered: July 2011
Location: Pakistan
Junior Member

Dear Folks,

Attached is my designed form & below is my code on delete button.

The problem is that 1 or more less records are deleted from selected, i.e when i select 5 record 3 records are deleted, when i select 2 records 1 record is delete. but when i select one record definately 1 record deleted.

Please help.

BEGIN
GO_BLOCK('CASEDISCHARGE_vu');
First_Record;
LOOP
IF :CASEDISCHARGE_vu.CHECK = 'Y' THEN
SET_BLOCK_PROPERTY('CASEDISCHARGE_vu', DELETE_ALLOWED, PROPERTY_TRUE);
DELETE_RECORD;
END IF;
Exit when :System.Last_Record = 'TRUE';
Next_Record;
END LOOP;
commit;
SET_BLOCK_PROPERTY('CASEDISCHARGE_vu', DELETE_ALLOWED, PROPERTY_FALSE);
set_block_property('CASEDISCHARGE_VU',DEFAULT_WHERE,'CAUSELISTMID='||:GLOBAL.CAUSELISTMID);
GO_BLOCK('CASEDISCHARGE_VU');
EXECUTE_QUERY;
END;

Thanks
Waseem
  • Attachment: disch.png
    (Size: 46.60KB, Downloaded 796 times)
Re: Delete Multiple Records [message #606468 is a reply to message #606446] Fri, 24 January 2014 05:48 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Code looks OK to me (or I don't see what might be causing what you described), unless DEFAULT_WHERE doesn't return what you expected. Just to test it, remove SET_BLOCK_PROPERTY and issue EXECUTE_QUERY right after the loop.

As you're on 6i, put MESSAGE calls into this trigger so that you could follow its execution. Hopefully, you'll find what causes the problem.
Re: Delete Multiple Records [message #606513 is a reply to message #606468] Sat, 25 January 2014 03:58 Go to previous messageGo to next message
whmemon
Messages: 26
Registered: July 2011
Location: Pakistan
Junior Member

Resolved.

else condition was missing.

Updated code as follows.

Thanks for response.

IF :CASEDISCHARGE_vu.CHECKED = 1 THEN
SET_BLOCK_PROPERTY('CASEDISCHARGE_vu', DELETE_ALLOWED, PROPERTY_TRUE);
DELETE_RECORD;
ELSE
Next_Record;	
END IF;
Re: Delete Multiple Records [message #606529 is a reply to message #606513] Sat, 25 January 2014 13:55 Go to previous messageGo to next message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
That doesn't make much sense. If IF statement failed (i.e. returned FALSE), the current record wasn't deleted so statements that follow IF were executed: first it was the EXIT (which checks whether you're on the last record, and does nothing until you really ARE on the last record), and the next line is NEXT_RECORD.

So, how did that "updated code" work properly, as opposed to what you've had earlier?
Re: Delete Multiple Records [message #606560 is a reply to message #606529] Sun, 26 January 2014 23:35 Go to previous message
whmemon
Messages: 26
Registered: July 2011
Location: Pakistan
Junior Member

Yes Littlefoot, Its working fine.

Previous Topic: use of $$DBDATETIME$$ at other than initial value
Next Topic: CONCEAL_DATA
Goto Forum:
  


Current Time: Thu Apr 25 12:20:46 CDT 2024