Delete detail block single record [message #452477] |
Thu, 22 April 2010 05:34 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shagar
Messages: 6 Registered: April 2010 Location: coimbatore
|
Junior Member |
|
|
My form consist two datablock cust_mstr,cust_dtls, each customer code consists two or three contact details records, when i delete the single detail record instead of deleting single record it deletes all the details records from cust_detail table.
Here by i attaching my form for your reference pls find the code in delete button
Regards
Shagar.M
|
|
|
|
Re: Delete detail block single record [message #452482 is a reply to message #452480] |
Thu, 22 April 2010 05:58 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shagar
Messages: 6 Registered: April 2010 Location: coimbatore
|
Junior Member |
|
|
/* Formatted on 22.04.2010 13:08:49 (QP5 v5.136.908.31019) */
DECLARE
v_delete NUMBER;
BEGIN
IF :BLK_EMP_MSTR.TXT_EMP_CODE IS NOT NULL
THEN
SET_ALERT_PROPERTY ('alt_delete',
alert_message_text,
'Do You Want to Delete?');
v_delete := SHOW_ALERT ('alt_delete');
IF v_delete = alert_button1
THEN
DELETE FROM TBL_EMP_MSTR
WHERE EMP_CODE = :BLK_EMP_MSTR.TXT_EMP_CODE;
COMMIT;
DELETE_RECORD;
COMMIT;
CLEAR_BLOCK (no_validate);
DELETE FROM TBL_EMP_DTLS
WHERE EMP_CODE = :BLK_EMP_DTLS.TXT_DTLS_EMP_CODE;
COMMIT;
DELETE_RECORD;
CLEAR_BLOCK ('');
COMMIT;
END IF;
END IF;
END;
CLEAR_FORM;
above posted code is delete button when i place the cursor in detail block in any record and i press delete button instead of deleting single record. It deleting all the records
CM: Added [code] tags, which I asked you to do, please do so next time.
LF: reformatted code
[Updated on: Thu, 22 April 2010 06:09] by Moderator Report message to a moderator
|
|
|
Re: Delete detail block single record [message #452484 is a reply to message #452477] |
Thu, 22 April 2010 06:04 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Why are you using clear_block?
Are you sure that all the records are being deleted? I suspect they are just being cleared from the form by the clear_block.
You shouldn't need clear_block at all.
|
|
|
|
Re: Delete detail block single record [message #452486 is a reply to message #452477] |
Thu, 22 April 2010 06:18 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
deepankar_04
Messages: 29 Registered: August 2009 Location: Udaipur, Rajasthan, INDIA
|
Junior Member |
|
|
Quote:First you put this question in forms tag.
You have change or write the code in ON-CHECK-DELETE-MASTER trigger of Master block. Also if you want particular detail record/s to remove then you should take care of :System.cursor_item i.e. on deleting you should also go to detail block.
Your code, I have seen is not seem to be proper,
because in that code you have first delete the master records and then detail records. This should be wrong. If you want to delete a master record then you should delete all the related records in detail table first.
Also for deleting a particular record from detail table you should have to mention a one more where clause's condition besides CUST_CODE.
|
|
|
|
Re: Delete detail block single record [message #452495 is a reply to message #452485] |
Thu, 22 April 2010 07:02 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Littlefoot wrote on Thu, 22 April 2010 12:15
Furthermore, you don't really need DELETE statement - DELETE_RECORD + COMMIT would do both.
The deletes appear to be for other tables than the ones the blocks are based on, so they may be necessary. I was going to make that point myself until I noticed.
|
|
|
Re: Delete detail block single record [message #452503 is a reply to message #452495] |
Thu, 22 April 2010 07:30 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shagar
Messages: 6 Registered: April 2010 Location: coimbatore
|
Junior Member |
|
|
I removed (delete_record) and (commit) and also delete the code in (on-check-delete-master), but the record is not deleting.
If i using ctrl+f11 and retrieve the record it will be deleted .But when i am retrieving the record from LOV and press the button its not deleted it will be insert the record in detail table.
Please send me solution how to delete the record in detail block and then delete the record in master block
|
|
|
Re: Delete detail block single record [message #452517 is a reply to message #452477] |
Thu, 22 April 2010 07:53 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
cookiemonster
Messages: 13963 Registered: September 2008 Location: Rainy Manchester
|
Senior Member |
|
|
Why do you want to delete the record in master block.
Previously you said it was getting rid of all the records and you didn't want that, but you have to get rid of all the detail records to be able to delete the master record.
|
|
|
Re: Delete detail block single record [message #452605 is a reply to message #452517] |
Thu, 22 April 2010 23:58 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
shagar
Messages: 6 Registered: April 2010 Location: coimbatore
|
Junior Member |
|
|
OK i cleared coding in delete button.If i place the cursor in master block and press the button the entire record should be deleted including the detail block also and if i place the cursor in detail block and press the button only the detail block record should be deleted and not the master block. Please give me the solution.
|
|
|
|
|