Subject Re: [IBO] Parameterized "execute block" statement with IB_DSQL
Author Marcin Bury
Patrick

Add 
IB_DSQL1.Prepare 
before assigning parameters values and then try.

HTH
Marcin

------ Wiadomość oryginalna ------
Od: "patrick_marten@... [IBObjects]" <IBObjects@yahoogroups.com>
Data: 24.10.2018 18:01:05
Temat: [IBO] Parameterized "execute block" statement with IB_DSQL

Hello,

am I wrong in the assumption, that a TIB_DSQL component could be used to execute a statement like this?

execute block
as
declare TempID int;
declare TempString varchar(10);
declare TempInteger integer;
begin
    select SETTING_VALUE from SETTINGS where (ID = 1) into :TempString;
    begin
        TempInteger = cast(TempString as integer);
        when any do TempInteger = 2;
    end
 
    for select ID from PENDING_UPDATES where (PARAM1 = :PARAM1) and (PARAM2 = :PARAM2) into :TempID do begin
        execute procedure SOME_PROCEDURE(:TempID, TempInteger, 'now');
    end
    delete from PENDING_UPDATES where (PARAM1 = :PARAM1) and (PARAM2 = :PARAM2);
end

When I try to assign the parameter values by either

IB_DSQL1 .ParamByName('PARAM1').AsInteger := xxx;
IB_DSQL1.ParamByName('PARAM2').AsInteger := xxx;

or

IB_DSQL1.Params.Values['PARAM1'] := xxx;
IB_DSQL1.Params.Values['PARAM2'] := xxx;

I get an error message "Column unknown: PARAM1".

When I replace the :PARAM1 and :PARAM2 parts in the SQL statement directly by some values, it works.

Am I doing anything wrong?

Usually I use a TIB_Script for non-parameterized "execute block" statements, but in this case I need some parameters to pass in, so I thought TIB_DSQL is the way to go, because parameters seem to be supported by it, but somehow it doesn't work...