Subject Re: [IBO] Pulling my hair out: ParamByName stopped working
Author mitch_landor
--- In IBObjects@yahoogroups.com, "Alan McDonald" <alan@...> wrote:
>
> > I'd be grateful for any assistance with this which is driving me nuts.
> >
> > This procedure calls a query which successfully returns all rows if I
> > comment out the ParamByName line in the procedure and the parameter in
> > the query.
> >
> > If I remove the commenting out, zero rows are returned, even though
> > the variable "curr_proj_version" is correctly set and there are
> > definitely rows in the table that match. I can manually enter the
> > chosen value for "curr_proj_version" in the query and open the dataset
> > and get the required rows.
> >
> > Any ideas why this might not be working?
> >
> > Thanks
> >
> > Mitch
>
> there could be many reasons why this doesn't work. you need to show
us the
> table definition as well as the value you are assiging to the parameter.
> But mainly I suspect that it is because you are not aliasing the
pversion_id
> field when assigning the parameter and this field is also in one or
more of
> the other tables.
> If you are using FB2 then this ambiguity would not be tolerated but
earlier
> versions will accept it and provide unexpectd results if no aliasing is
> done.
> Alan
>

Thanks Alan for your help. What exactly do you mean by aliasing?

Mitch


> >
> > procedure TfrmProjectContainer.SpecificationsTabShow(Sender: TObject);
> > begin
> > with DataModule5 do
> > begin
> > if not IBODatabase1.Connected then
> > IBODatabase1.Connect;
> >
> > if qryCurrProjSpecs.Active then
> > qryCurrProjSpecs.Unprepare;
> > qryCurrProjSpecs.prepare;
> > with qryCurrProjSpecs do
> > ParamByName('Var_PVERSION_ID').asinteger := curr_proj_version;
> > qryCurrProjSpecs.Open;
> > end;
> > end;
> >
> >
> > =====
> > qryCurrProjSpecs:
> >
> > select
> > spec.spec_id,
> > spec.pversion_id,
> > spec.spec_descr,
> > spec.supplier_ref,
> > spec.unitcost_est,
> > spec.unitcost_act,
> > spec.approved,
> > spec.unitdelivcost,
> > spec.act_leadtime,
> > spec.est_leadtime,
> > spec.spec_active,
> > spectype.name_eng spectype_name,
> > spec.specattr_fabric_id,
> > spec.specattr_misc_id,
> > spec.specattr_elec_id,
> > uom.code uomcode,
> > party.shortname supplier_shortname,
> > spec.spectype_id
> > from spec
> > inner join spectype on (spec.spectype_id = spectype.spectype_id)
> > inner join uom on (spec.uom_id = uom.uom_id)
> > inner join party on (spec.supplier_id = party.party_id)
> >
> > where
> > (
> > (pversion_id = :var_PVERSION_ID)
> > )
> >
>