developer 2000 key-delrec

From: <ssharma24_at_my-deja.com>
Date: Tue, 04 Apr 2000 22:06:34 GMT
Message-ID: <8cdp0v$uca$1_at_nnrp1.deja.com>



[Quoted] [Quoted] I have a form that is based on a table that has two fields in it (id, name). One field (id) of that table is based on a database sequence (it gets created as you add data to the other field). We are not showing the sequence field on the form.
I have key-delrec on the the block that has code that checks for any child records . (The sequence key field (ID) is a foreign key in another table, we check for child records based on the sequence key field. The “name field is not referenced in any other table).

My question is:
Although I do have a key-delrec to stop the deletion of a “record”, but I am being able to delete the ‘name’ field. I don’t want user to be able to delete the ‘name’ field if the id related to it has child records.

I wrote some code like this: (what trigger do I put it in or is it the write code????)
declare
vcount number;
vid varchar2(10);
cursor name_check is
select id from A
where name = :block.name;

begin
open name_check;
fetch name_check into vid;
close name_check;

  SELECT COUNT (*)
  INTO vCount
  FROM B
  WHERE id IS NOT NULL
  and id = vid;

  IF vCount <> 0 THEN

     bell;
   message(‘message’);
   message(' ',no_acknowledge);

  end if;

End;

Sent via Deja.com http://www.deja.com/
Before you buy. Received on Wed Apr 05 2000 - 00:06:34 CEST

Original text of this message