Re: preventing 2 rows with same "flag" set

From: Eric Givler <egivler_at_flash.net>
Date: Wed, 11 Oct 2000 13:23:46 GMT
Message-ID: <CRZE5.1506$ln6.174917_at_news.flash.net>


Ok...

[Quoted] [Quoted] I opened the form, put the code in the when-checkbox-changed, and then ran it. I queried on a user
with 2 locations. I set the checkbox on each row and then committed and now have two flags. Forms
doesn't post the data between record movements on a single block form, so it doesn't SEE the other flag
as set in the database when the trigger fires.

I also want to allow this for updates too. If there's a primary, I should be able to uncheck it, then re-check
another one.

[Quoted] I wasn't sure why the code you posted didn't check to see that the user has actually SET THE
FLAG. It just checks for a flag already set.

Any additional input greatly appreciated, and thanks for the help so far.

Matt B. <mcb_at_fightspam.sd.znet.com> wrote in message news:su7nbjfl1a6df_at_corp.supernews.com...
> "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 - 15:23:46 CEST

Original text of this message