Subject | Re: [IBO] Params |
---|---|
Author | Geoff Worboys |
Post date | 2001-07-19T09:28:32Z |
Hi Nando,
weren't having much luck elsewhere I thought it was worth trying.
After all a statement like...
SELECT ANAME FROM ANAME WHERE ANAME=:ANAME
is a little confusing to read, even if it is strictly legal.
In the case of automatically generated insert/update statements I dont
bother changing what is generated - to me this is a special case where
you are equating the server field name with the client field value.
This is not what true with a parameter in a where clause, the
parameter is a distinctly different object to the field.
When creating explicit sql (stuff I type myself) I do try to avoid
using the same names. (Not sure how consistent I am but I do try ;-)
I find it helpful in avoiding confusion and picking up typos. For
example; when typing field/param names into properties or into
functions like xxxxByName, it is one way of being doubly sure you've
done what you intended.
In my SQL you will find things like...
SELECT ANAME FROM NAMES WHERE ANAME=:INPUT_ANAME
Also, in IBO4, I sent Jason some changes which will allow parameter
attributes to be defined from the various Fields* properties (such as
the displaylabel etc). For this to work as desired, you will probably
want to identify the parameters from fields. This feature is off by
default, set TIB_Query.SetParamAttribs=true to turn it on.
That feature is part of an extension to the native controls (see the
ParamName property on the TIB_* controls) which turns the controls
into parameter editors.
So it probably does not matter, just my preference.
Geoff Worboys
Telesis Computing
> > For best clarity of code avoid using parameter names thatI did say that I did not think it was Gordon's problem, but since we
> > are the same as the field or table names.
>
> never thought about that; I've been using for the parameters
> the same name as the fields for years; I even seem to recall
> that something in the DB VCL (perhaps in the ClientDataSet
> param binding) actually relies on that.
> BTW, even the IB_Query editor does generate update statements
> formed in this way. Do you manually change them? Just curious.
weren't having much luck elsewhere I thought it was worth trying.
After all a statement like...
SELECT ANAME FROM ANAME WHERE ANAME=:ANAME
is a little confusing to read, even if it is strictly legal.
In the case of automatically generated insert/update statements I dont
bother changing what is generated - to me this is a special case where
you are equating the server field name with the client field value.
This is not what true with a parameter in a where clause, the
parameter is a distinctly different object to the field.
When creating explicit sql (stuff I type myself) I do try to avoid
using the same names. (Not sure how consistent I am but I do try ;-)
I find it helpful in avoiding confusion and picking up typos. For
example; when typing field/param names into properties or into
functions like xxxxByName, it is one way of being doubly sure you've
done what you intended.
In my SQL you will find things like...
SELECT ANAME FROM NAMES WHERE ANAME=:INPUT_ANAME
Also, in IBO4, I sent Jason some changes which will allow parameter
attributes to be defined from the various Fields* properties (such as
the displaylabel etc). For this to work as desired, you will probably
want to identify the parameters from fields. This feature is off by
default, set TIB_Query.SetParamAttribs=true to turn it on.
That feature is part of an extension to the native controls (see the
ParamName property on the TIB_* controls) which turns the controls
into parameter editors.
So it probably does not matter, just my preference.
Geoff Worboys
Telesis Computing