On top of Bryan Love's posting,
you may try something like (depending on the DB
design):

Assume you're using MS SQL Server

query name=YouNameIt DS=yourDS

-- set non-category item(s) var
-- set category item flag var
Declare @nonCat varchar(500);
Declare @CatFlag int=0;

-- check items and do insertion
set nocount on;
If exists (select * from ItemsTBL
    where categoryID = 2
       -- cateogry lookup contains 'food' with ID of 2
       -- categoryID is a FK in ItemsTBL
    and itemsID IN (#FORM.selectedItemIDs#)
       /* in the UI Form, I assume you'll use a field
        named selectedItemIDs for each item, e.g. milk
       */
    ) 
    -- turn flag on
    set @CatFlag = 1
    Insert into SecondTBL ...;

-- check non-category item(s) if any
   select @nonCat = 
   (select item 
    from ItemsTBL
    where categoryID != 2
     and itemsID IN (#FORM.selectedItemIDs#)
   )

-- process status report
   set nocount off;
   select @nonCat as ItemsYouCantGet, @CatFlag as
ItemsChecked;

close query

inside cfoutput
do evaluation, 
if Len(queryName.ItemYouCantGet) GT 0,
then #item# cannot be checked out

if queryName.ItemsChecked EQ 1
then, some items ...

Anyway, I think it should work, no time to test on my
end.

Regards,

DL

--- Bryan Love <[EMAIL PROTECTED]> wrote:
> sounds like you'd need something like this:
> 
> SELECT ...
> FROM table
> WHERE itemID IN (#idList#) AND type = 'food'
> [idList is a comma-delimited list of item IDs]
> 
> Assuming your list (sugar, milk, tv, flour) is
> actually a list of IDs the
> above query will return information on the rows you
> desire.  I also assume
> you have a column (type) that can be used to
> differentiate the items.
> 
> +-----------------------------------------------+
> Bryan Love
>   Macromedia Certified Professional
>   Internet Application Developer
>   Database Analyst
> TeleCommunication Systems
> [EMAIL PROTECTED]
> +-----------------------------------------------+
> 
> "...'If there must be trouble, let it be in my day,
> that my child may have
> peace'..."
>       - Thomas Paine, The American Crisis
> 
> "Let's Roll"
>       - Todd Beamer, Flight 93
> 
> 
> 
> -----Original Message-----
> From: Janine Jakim [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, September 19, 2002 9:55 AM
> To: CF-Talk
> Subject: Run a check before an insert
> 
> 
> Ok I need to make a check on one table before I do
> an insert into another
> table. (Kind of similar to a login where the 1st
> query checks the
> username/2nd query checks the group). But I want to
> be able to have the 1st
> table be able to check for several rows in the first
> query and only insert
> the matches into the second query.
> So an example is: I am restricted to only ordering
> food items.  I order
> sugar, milk, a tv and flour.  I want the first query
> to look at the order
> then send to the 2nd query the order for sugar, milk
> and sugar, leaving out
> the tv. (and maybe sending a message to the
> user...sorry you can't order
> that...)
> I can't seem to get my loops right on this one- I
> either seem to be able to
> add all or nothing.
> Thanks in advance,
> Janine
> 
>

______________________________________________________________________
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to