Subject Re: [firebird-support] Sets in like operator
Author Helen Borrie
At 04:03 AM 24/01/2007, you wrote:
>¿ There is any way to use character sets with like operators ?.

I won't confuse the issue by answering the above question. :-)

>Something like : (costumers starting whth a, b, c, d or f)
>
>select * from costumer where name like '[a-f]%'
>
>I can't find it in Beta Documentation of Interbase 6, ¿ what's such
>sintaxis ?.

No. There is only one predicate that can process
a list: IN(). You could use it like this:

where
....
substring(costumers from 1 for 1) in ('a', 'b', 'c', 'd', 'f')

>(I know I can build a query with some clauses separated with or, but I
>will prefer to not have to generate dinamic querys).

I guess by this statement that you want to write
a query for your application that can take an
arbitrary set of characters as a single
parameter. That is not currently available in DSQL.

You could write a stored procedure that takes a list of values as input, e.g.

create procedure retrieve_from_list(input_list varchar(70)
returns (<.....>)
as
...

Your PSQL code breaks down the list internally in
a WHILE loop, picking out each value, one by one,
into a local variable. An embedded
FOR...SELECT...INTO loop takes the latest value
of the variable as the parameter for a 'starting
with :aVariable' clause in the SELECT specification.

You would have to take care that the list
argument was defined to be long enough to
accommodate the longest possible list.

./heLen