Subject | Re: How to use a an integer parameter to fetch parameter = "N" or all rows. |
---|---|
Author | mlq97 |
Post date | 2007-05-30T08:31:22Z |
--- In firebird-support@yahoogroups.com, "Sasha" <selectnull@...> wrote:
I would really like to avoid building the query dynamically.
I don't understand:
case 1: set :all_location to 0
case 2: set :all_location to 1.
Is this some kind of switch to disregard this parameter? Where is
there documentation on this?
>Thanks Sasha,
> >
> > How can I easily query an integer column to get the rows matching
> > an integer or also allow all rows to be fetched? EG:
> >
> > Item.Project (integer)
> > Item.Location (integer)
> >
> > (Case 1)
> > Select * from Item where
> > Project = :ProjectID and Location = LocationID
> >
> > (Case 2)
> > Select * from Item where
> > Project = :ProjectID and Location = all locations
> >
>
> select * from Item where
> Project = :ProjectId and (Location = :LocationID or :all_locations = 1)
>
> case 1: set :all_location to 0
> case 2: set :all_location to 1
>
> Or, you can dynamically build a query and skip " and Location = ..."
>
> Sasha
>
I would really like to avoid building the query dynamically.
I don't understand:
case 1: set :all_location to 0
case 2: set :all_location to 1.
Is this some kind of switch to disregard this parameter? Where is
there documentation on this?