Ask the Expert

Error trying to delete a particular record

I am trying to delete a particular record selected using a LOV.

This is the code that I am trying to use. It does not work 100%. The first record is deleted instead and the one I am trying to delete becomes the first record.

If I try to delete it again then I get an error message: FRM-40657 Record deleted by another user. Otherwise I get the error message FRM-40509 Unable to update record.

The records are being deleted from the V_BASE table even though I am getting these errors.


Code for Delete Button:

DECLARE
	
	ALERT_BUTTON NUMBER;
	
BEGIN

	ALERT_BUTTON:= SHOW_ALERT('DELETE_CAUTION_ALERT');
	
	IF ALERT_BUTTON=ALERT_BUTTON1 THEN
		DELETE FROM CUSTOMER
		WHERE :CUSTOMER.CUSTOMER_NO = CUSTOMER.CUSTOMER_NO;
		COMMIT;
		ALERT_BUTTON:= SHOW_ALERT('DELETE_SUCCESSFUL_ALERT');
		MESSAGE('RECORD HAS BEEN DELETED SUCCESSFULLY');
	ELSIF ALERT_BUTTON=ALERT_BUTTON2 THEN
		ROLLBACK;
		ALERT_BUTTON:= SHOW_ALERT('DELETE_CANCELLED_ALERT');
		MESSAGE('NO RECORDS HAVE BEEN DELETED');
	
	END IF;
END; 

    Requires Free Membership to View

Is the block you are deleting the record from a BASE table block or a non-V_BASE table block?

I get the feeling you are locking the record yourself based on the information you provided me.

Maybe you want to just say:

 IF ALERT_BUTTON=ALERT_BUTTON1 THEN
  delete_record;  -- A FORM'S API;
...

This should suffice.

Please note there is no NEED to do anything if the user hits cancel (i.e. no need to right code for ALERT_BUTTON2).

This was first published in June 2004

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: