|Subject||Re: [firebird-support] Value from parmeter-dependant colum in where clause|
> I have run into a problem that I thought I had a nice solution for but mysolution doesn't seem to work.
>depending on one of the in-parameters (to a stored procedure).
> I want my select statement to return a value from a different column
> If I simplify the problem I have two different price columns and which oneto use is dependant on one of parameters to the SP.
>doesn't make sense, what then would be the reason for the "AS" statement?
> I thought the select query could look like this:
> select name,
> case (:type = 1) then priceA
> case (:type = 2) then priceB
> end as Price
> where Price > 10
> from myTable
> into name_out, price_out
> do suspend;
> Where PriceA and PriceB are columns in myTable
> This doesn't work , I get the following error message
> Column does not belong to referenced table.
> Dynamic SQL Error.
> SQL error code = -206.
> Column unknown.
> I recall that it works if I don't use Price in the where clause but that
>value of an in parameter?
> Is there another way to return the value of a column depending on the
>rather large and I have already done that to get around a similar
> It is not reasonable to put the whole select in a if clause because it is
end as Price
where Price > 10
into name_out, :v_PriceA, :v_PriceB
if (type = 1)
then price_out = v_PriceA;
else price_out = v_PriceB;
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL