Unable to delete new record because of when_new_record Trigger. [message #414467] |
Wed, 22 July 2009 05:16 |
pranabpranab4u
Messages: 5 Registered: July 2009
|
Junior Member |
|
|
Hi David,
I have a form where there are multiple detail records are displayed. The Fields of the detail records are something like "Deal_no", "First_collct_date","Last_collect_date" and so on. In the Action block I have buttons called OK, Add_New_line, Delete, Cancel and so-on.
I will disable the delete button depending upon the First_collct_date. condition
1.If First_collct_date<sysdate then disable the "Delete" button.
2. If Last_collect_date < sysdate then enable "Delete" button.
3. If First_collct_date> sysdate or First_collct_dateis null (in case newly added record) then enable the "Delete" button.
Problem:
when I have the first record which is satisfies condition 1 (above) and try to add the new record. When I click on "Delete" button, the when_validate_record is fires and not able to delete the record.
Sample Code:
I have written condition 1 2 and 3 in WHEN-NEW-RECORD-INSTANCE in the detail block.
code is :
...
if (:B_fixed_deal.status = 'I' and :B_fixed_deal.collect_end_date < L_vdate) then
RWIDGET.TURN_ON('B_action.PB_delete_line');
elsif :B_fixed_deal.collect_start_date >= L_vdate or :B_fixed_deal.collect_start_date is null then
RWIDGET.TURN_ON('B_action.PB_delete_line');
else
RWIDGET.TURN_OFF('B_action.PB_delete_line');
end if;
...
Could you please suggest me who can I solve the problem.
please let me know, in case you need more info.
Thanks,
Pranab
|
|
|
|
|
|
|
|
Re: Unable to delete new record because of when_new_record Trigger. [message #414907 is a reply to message #414711] |
Fri, 24 July 2009 00:23 |
pranabpranab4u
Messages: 5 Registered: July 2009
|
Junior Member |
|
|
Thanks for your reply. But this code only disable the Delete button, when it is pressed and the condition is met. but it has to be something like :- if the record is not allowed to delete, then Delete button should be disabled.
Could you please any other solution where, I can disable and enable the button when ever I select any particular record.
Thanks in advance,
Pranab
|
|
|
|
Re: Unable to delete new record because of when_new_record Trigger. [message #414923 is a reply to message #414864] |
Fri, 24 July 2009 01:07 |
pranabpranab4u
Messages: 5 Registered: July 2009
|
Junior Member |
|
|
Hi David,
Thanks for your reply. But I am really sorry, I am not able to understand what NULL value you are talking about. I thought you are talking about ":B_fixed_deal.collect_start_date is null"
So I modified the for testing like "elsif nvl(:B_fixed_deal.collect_start_date,'20-DEC-2009') >= L_vdate". But I got the same error.
May be I am wrong. Could you please suggest me how you are looking for handling the NULL. Also let me know If you need any more info from my end.
Thanks and Regards,
Pranab
|
|
|
Re: Unable to delete new record because of when_new_record Trigger. [message #415262 is a reply to message #414923] |
Sun, 26 July 2009 23:41 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
Always use a to_date or to_char when testing date fields. It was to avoid this problem of date strings that I suggested turning 'off' the delete feature, without condition or exception, at the beginning of the trigger and only turning it back on if a condition is met.
David
|
|
|