Subject RE: [IBO] Error with parameters
Author Support List
Andrei,

> Today I installed the newest IBO version, and now I'm getting an error
> in the following code:
>
> Procedure CalculaTotal;Var qry_tmp : TIB_Query;Begin  qry_tmp :=
> TIB_query.Create(Self);  qry_tmp.DatabaseName :=
> dm.cnSistema.DatabaseName;  qry_tmp.SQL.Text := 'Select
> Coalesce(sum((qtde  - estorno) *valor), 0) as totPedido, '+
>                    ' Coalesce(sum((qtde  - estorno) *
> valor_compra_original), 0) as totCompraPedido, '+
>          ' Coalesce(sum((qtde  - estorno) * valor_lista), 0) as
> totPedidoLista '+                               'from pedidosItens
> where orcamento_id = :worc_id group by orcamento_id';
> qry_tmp.ParamByName('worc_id').asInteger
> :=dm.qrOrcamentos.FieldByName('Registro_id').AsInteger;
> qry_tmp.Open;end;
> The error is 'Project project1.exe raised exception class
> EIB_StatementError with message 'Field: worc_id not found'.
> If I open the query before I feed the parameter, the error doesn´t
> occur. But this seems that I need to search in all my systems, and
> change several code lines.
>
> - Since which version this behavior was implanted?

I don't yet fully understand why you are having this problem.


> - What can I do to solve this without opening the query before feed
> the parameters?

You should be able to set parameter values prior to opening the query.


> - This is the best syntax? (First open the query and then feed the
> parameters) If so, I will do this from now on.

No, something else is wrong. You should be able to assign values to the
parameters prior to calling Open. I'm wondering if your installation of the
new version is having problems due to old compiled code or something else
making your system unstable.

Jason