Home » Developer & Programmer » Forms » Delete detail block single record (Oracle Forms 10g)
Delete detail block single record [message #452477] Thu, 22 April 2010 05:34 Go to next message
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 #452480 is a reply to message #452477] Thu, 22 April 2010 05:47 Go to previous messageGo to next message
cookiemonster
Messages: 13938
Registered: September 2008
Location: Rainy Manchester
Senior Member
Unfortunately I can't open your form properly. Can you post the code from the delete button in the thread. Use [code] tags - see the forum guide if you're not sure how.
Re: Delete detail block single record [message #452482 is a reply to message #452480] Thu, 22 April 2010 05:58 Go to previous messageGo to next message
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 messageGo to next message
cookiemonster
Messages: 13938
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 #452485 is a reply to message #452482] Thu, 22 April 2010 06:15 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Why 4 commits? Only one should be sufficient.

DELETE_RECORD deletes record in a current block. As your DELETE statements delete records from _MSTR and _DTLS tables, I suspect that you wanted to remove a record from master and detail blocks (on the screen, that is). However, as you didn't change data block, you are deleting records from the same block all the time.

Furthermore, you don't really need DELETE statement - DELETE_RECORD + COMMIT would do both.

What is CLEAR_BLOCK('') supposed to do?
Re: Delete detail block single record [message #452486 is a reply to message #452477] Thu, 22 April 2010 06:18 Go to previous messageGo to next message
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 #452491 is a reply to message #452486] Thu, 22 April 2010 06:49 Go to previous messageGo to next message
shagar
Messages: 6
Registered: April 2010
Location: coimbatore
Junior Member
Ya i used one or more where clause but it inserting the record in detail table
Re: Delete detail block single record [message #452495 is a reply to message #452485] Thu, 22 April 2010 07:02 Go to previous messageGo to next message
cookiemonster
Messages: 13938
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 messageGo to next message
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 messageGo to next message
cookiemonster
Messages: 13938
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 messageGo to next message
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.
Re: Delete detail block single record [message #452621 is a reply to message #452605] Fri, 23 April 2010 01:12 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Quote:
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

You don't have to do anything - this is Forms default behavior.

Quote:
If i place the cursor in master block and press the button the entire record should be deleted including the detail block

Set relation's "Delete Record Behavior" property to "Cascading".
Re: Delete detail block single record [message #452664 is a reply to message #452621] Fri, 23 April 2010 03:59 Go to previous message
shagar
Messages: 6
Registered: April 2010
Location: coimbatore
Junior Member
Its working Thank you
Previous Topic: Record 1/? "Counter"
Next Topic: Next record
Goto Forum:
  


Current Time: Fri Sep 20 09:30:59 CDT 2024