Subject Stored procedure SQL problem
Author Svilen Stefanov
Hi guys ,

I want to write stored procedure to do the following thing. :
select * from Table1 where Column1 = :Param1 , Column2 = :Param2 .........

but if the Param1 = null then I want the procedure to exclude " Column1 =
:Param1". So sql code will be something like :

select * from Table1 where Column2 = :Param2

I thought that "case" statement will do the job :

select * from Table1 where
Column1 = case :Param1 is null then Column1 else :Param1 end and
Column2 = case :Param2 is null then Column2 else :Param2 end

In this SQL If Param1 is null then then select must be "select * from Table1 where Column1=Column1 and Column2=:Param2" . If I execute this in SQL editor everything is OK , but the stored procedure with "case" statement doesn't work like this "select" statement. Is this a bug or I am missing something.

Keep in mind that I have many params and many columns. Do you think this is
possible with FireBird 1.5 ?


Thanks in advance !



[Non-text portions of this message have been removed]