Subject [firebird-support] SP Parameter as sql statement ?
Author Martin Dew
Hi,



I have a need to pass an additional Where statement element on the fly
into a stored procedure, this wherestatement1 parameter will need to
contain p.area in ('AAA','BBB','CCC') ;



CREATE PROCEDURE TEST1 (

DATEFROM DATE,

DATETO DATE,

WHERESTATEMENT1 VARCHAR(250)

) RETURNS (

TOTAL INTEGER

) AS

BEGIN

FOR

SELECT

count(l.urn)

FROM

log l

left outer join patient p on (l.urn = p.log_urn)



WHERE

(l.taken_at >= :DATEFROM

and

l.taken_at <= :DATETO)

and

(:Wherestatment)

INTO

:TOTAL

DO BEGIN

SUSPEND;

END

END



This is not allowed by the compiler, so my questions is how would you
approach it ? I need to run the stored procedures for infitate differe
configurations of this optional where statement, so do not want to have
to write literally thousands of alternative SP's.



Any help on approach would be much appreciated.



Martin



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