Subject | RE: [firebird-support] Re: Conditional conundrum |
---|---|
Author | Helen Borrie |
Post date | 2005-10-21T00:12:23Z |
At 02:46 PM 20/10/2005 -0400, you wrote:
(or is allowed to be) a column name? That is what is not supported.
I don't seem to be alone is missing what you're trying to get here. You
appear to be using the IN() predicate to test for a 1:1 equality.
Suppose for a moment that you are, after all, passing a value in :param
that might be 'U' or some other character. You want to find (presumably
multiple) rows where one of the following two conditions applies
exclusively. You have decided to use a stored procedure to get this set
because SQL doesn't support XOR.
unit_use = 'U' and the value in :param is 'U'
unit_use <> 'U' and the value in :param is anything but 'U'
In the SP, you're not interested in any rows where unit_use is 'U' if the
value in :param isn't 'U', right? Then branch the logic before you do the
query:
begin
if (param = 'U') then
for select <set-delimited-list> from some_big_join
where delimited.unit_use = 'U'
into <list-of-variables> do
begin
....
end
else
begin
for select <set-delimited-list> from some_big_join
where delimited.unit_use <> 'U'
into <list-of-variables> do
begin
....
end
end
end
Or something else?
./heLen
>SelectA parameter *is* a value. Is your error in supposing that your :param is
> *
>From
> some_big_join
>Where
> (unit_use in ('U') and :param in ('U')) or
> (unit_use not in ('U') and :param not in ('U'))
>
>The portion of the query that tests a parameter against a value isn't
>supported in Firebird.
(or is allowed to be) a column name? That is what is not supported.
I don't seem to be alone is missing what you're trying to get here. You
appear to be using the IN() predicate to test for a 1:1 equality.
Suppose for a moment that you are, after all, passing a value in :param
that might be 'U' or some other character. You want to find (presumably
multiple) rows where one of the following two conditions applies
exclusively. You have decided to use a stored procedure to get this set
because SQL doesn't support XOR.
unit_use = 'U' and the value in :param is 'U'
unit_use <> 'U' and the value in :param is anything but 'U'
In the SP, you're not interested in any rows where unit_use is 'U' if the
value in :param isn't 'U', right? Then branch the logic before you do the
query:
begin
if (param = 'U') then
for select <set-delimited-list> from some_big_join
where delimited.unit_use = 'U'
into <list-of-variables> do
begin
....
end
else
begin
for select <set-delimited-list> from some_big_join
where delimited.unit_use <> 'U'
into <list-of-variables> do
begin
....
end
end
end
Or something else?
./heLen