Is there any article explaining how to use parameterized queries in TSQLQuery ?
 
----- Original Message -----
Sent: Sunday, August 20, 2006 2:24 PM
Subject: [lazarus] parameterized queries

Hello.
 
I just tried to put some parameterized query on a form and pass the parameter's value through code.
The query is the following:
 
select distinct sampling_types.sampling_type,
    plants.plant,
    plants.department
from ((sampling_types join batches_microbs on
    (((sampling_types.sampling_type)=
    (batches_microbs.sampling_type)))) join plants
    on (((batches_microbs.plant) =
    (plants.plant))))
where batches_microbs.sampling_type is not null and
    plants.plant_active = true and
    plants.plant = :parameter
group by sampling_types.sampling_type,
    plants.plant,
    plants.user,
    plants.plant_active,
    plants.plant_report,
    plants.department
order by sampling_types.sampling_type,
    plants.plant,
    plants.department;
In the query above, ":parameter" should be the actual parameter. I wanted to pass the parameter's value through code, in the FormCreate event procedure, something like this:
SQLQuery1.Params.ParamByName('parameter').AsString:='NESTERILNE MASTI, KREME I GELOVI';
 
Well, when I try to set the query to be "Active", the following error occurs:
"Error. PQConnection1: Unknown fieldtype for parameter "parameter"."
 
What shoudl I do?
 
Thanks,
 
Zlatko

Reply via email to