prevent delete when details exist (merged) [message #174587] |
Mon, 29 May 2006 23:10 |
mfa786
Messages: 210 Registered: February 2006 Location: karachi
|
Senior Member |
|
|
hi master
sir
how i get my block_name because i check black name
it manse where the curser system give that block name
such as
i have two block dept and emp
on delete event i put this code
if block_name='emp' then
delete emp where deptno=:dept.deptno;
elsif block_name='dept' then
select count(*) into variablecount from emp where deptno=:dept.deptno;
if variablecount=0 then
delete dept where deptno=:dept.deptno;
else
meassage (system found matching record then no delete master record)
endif;
endif;
end;
please give me idea how i get block name
thanking you
aamir
[Updated on: Tue, 30 May 2006 01:49] by Moderator Report message to a moderator
|
|
|
|
urgent where i put this code for delete [message #174607 is a reply to message #174587] |
Tue, 30 May 2006 01:20 |
mfa786
Messages: 210 Registered: February 2006 Location: karachi
|
Senior Member |
|
|
hi master
sir this code is right for my requirment but when i put on_delete event system not respons or not delete record
where i put this code for conditional deletion
this is my code
declare
recno number;
begin
if :system.cursor_block='accbal' then
delete accbal where accid=:chartofacc.accid;
go_block('chartofacc');
next_record;
elsif :system.cursor_block='chartofacc' then
select count(*) into recno from accbal where accid=:chartofacc.accid;
if recno=0 then
delete_record;
go_block('chartofacc');
previous_record;
else
message ('system found matching record then no delete master record');
message ('system found matching record then no delete master record');
end if;
end if;
end;
please gide me which event i use
thanking you
aamir
|
|
|
|
Re: urgent where i put this code for delete [message #174615 is a reply to message #174612] |
Tue, 30 May 2006 01:47 |
|
Maaher
Messages: 7065 Registered: December 2001
|
Senior Member |
|
|
A nice feature of a RELATIONAL database like Oracle is that you actually can define relations in it. A side effect of this can be that you prevent the deletion of masters if detail records exist. In Forms you can also define relations have you tried that? And again you count all the details to find out if one exist. Bad practice, but it is your program not mine.
To answer your question (after all it is urgent ): a ON-DELETE replaces the default Forms delete. You have to create your own. Like Littlefoot suggested, move it to another trigger like PRE-DELETE. But it would be better if you used the standard forms relations.
MHE
EDIT: Topics merged.
[Updated on: Tue, 30 May 2006 01:50] Report message to a moderator
|
|
|