Re: preventing 2 rows with same "flag" set

From: Matt B. <mcb_at_fightspam.sd.znet.com>
Date: Tue, 10 Oct 2000 20:29:18 -0700
Message-ID: <su7nbjfl1a6df_at_corp.supernews.com>


[Quoted] "Eric Givler" <egivler_at_flash.net> wrote in message news:tNHE5.757$ln6.112709_at_news.flash.net...
> I have a one block form that has a "flag" that stands for "primary
> location". The user can have many locations that they are allowed access
> to, but only ONE primary. If the flag is set (the DB has a "Y" in it), then
> it is brought up as the default location when they enter the application,
> otherwise they have to select from a list.
>
> I've created a checkbox for the field, but how do I prevent/allow the user
> to only have ONE "flag" for all his locations instead of multiple? What
> triggers/code are necessary? I'm using Developer 1.3.2 (32-bit).
>
> Any ideas appreciated.

On WHEN-CHECKBOX-CHANGED:

v_flag_found BOOLEAN := FALSE;
v_dummy CHAR(1) := NULL;
cursor flag_checker is
select 'X' from my_table
where my_column = 'Y';

begin
open flag_checker;
fetch flag_checker into v_dummy;
if flag_checker%FOUND THEN

   v_flag_found := TRUE;
end if;
close flag_checker;

if v_flag_found THEN

   message('You cannot do this.');
   raise form_trigger_failure;
end if;

-Matt Received on Wed Oct 11 2000 - 05:29:18 CEST

Original text of this message