Subject Replacement of parameters within a stored procedure
Author SoftTech
Firebird v1.5

A SQL statement is stored in a table.

Inside of a stored procedure I need to retrieve this SQL statement, replace
:Param1 and :Param2 with actual values then execute it. I will of course
know the value, just don't know how to replace the :Param1 and 2 with the
value.

SELECT DISTINCT 1
FROM ACCT_CASE
INNER JOIN DEBT D ON (ACCT_CASE.ACCT_ID=D.ACCT_ID) and
(ACCT_CASE.CASE_ID=D.CASE_ID)
INNER JOIN DEBTOR_CASE_DEBT ON (D.ACCT_ID=DEBTOR_CASE_DEBT.ACCT_ID) and
(D.DEBT_NO=DEBTOR_CASE_DEBT.DEBT_NO) and
(D.CASE_ID=DEBTOR_CASE_DEBT.CASE_ID)
INNER JOIN PERSON PD ON (PD.PERSON_ID=DEBTOR_CASE_DEBT.PERSON_ID)
LEFT OUTER JOIN PER_ADDRESS PDPA ON (PDPA.PERSON_ID=PD.PERSON_ID)
LEFT OUTER JOIN ADDRESS PDA ON (PDA.ADDR_ID=PDPA.ADDR_ID)
LEFT OUTER JOIN ZIP_CODE ON (PDA.ZIP_CODE_ID=ZIP_CODE.ZIP_CODE_ID)
WHERE (ACCT_CASE.ACCT_ID = :Param1 AND
ACCT_CASE.CASE_ID = :Param2 AND
PDPA.DEFAULT_ADDRESS = 1 AND
ZIP_CODE.STATE_CODE = 'AZ')

Can this be done? If so, some guidance would be appreciated.

Thanks,
Mike