BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

TIBQuery.Params

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (InterBase Express)
View previous topic :: View next topic  
Author Message
Adalberto Baldini
Guest





PostPosted: Thu Feb 22, 2007 9:21 pm    Post subject: TIBQuery.Params Reply with quote



With BDS at design time I set params value to activate the query and
test it.
I set a Datasource to get run time params and set ParamCheck to true.
Before open the query I set only params not included in Datasource.

It happens that param values set at design time are not cleared and
resulting set of record is not the expected.

Something misunderstood ?

Thanks.
Adalberto
Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Fri Feb 23, 2007 1:16 am    Post subject: Re: TIBQuery.Params Reply with quote



Adalberto Baldini wrote:
Quote:
With BDS at design time I set params value to activate the query and
test it.
I set a Datasource to get run time params and set ParamCheck to true.
Before open the query I set only params not included in Datasource.

It happens that param values set at design time are not cleared and
resulting set of record is not the expected.

Something misunderstood ?

Not sure what you mean by "set a Datasource to get runtime params", If you
have set up parameters at design time, then those values will be used at run
time unless you explicitly change them (or do something to invalidate them
such as change the SQL).

--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
Working for yourself is great because you get to work half days, and
you can choose any twelve hours you want.
Back to top
Adalberto Baldini
Guest





PostPosted: Sat Feb 24, 2007 6:51 pm    Post subject: Re: TIBQuery.Params Reply with quote



Wayne Niddery [TeamB] wrote:
Quote:
Adalberto Baldini wrote:

Not sure what you mean by "set a Datasource to get runtime params", If you
have set up parameters at design time, then those values will be used at run
time unless you explicitly change them (or do something to invalidate them
such as change the SQL).

When you set a datasource in TIBQuery this doesn't mean that TIBQuery

should load from Datasource , param values from datasource.fields which
matche param.name ? like in master detail relationship ?

Adalberto
Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Sat Feb 24, 2007 10:41 pm    Post subject: Re: TIBQuery.Params Reply with quote

Adalberto Baldini wrote:
Quote:

When you set a datasource in TIBQuery this doesn't mean that TIBQuery
should load from Datasource , param values from datasource.fields
which matche param.name ? like in master detail relationship ?

Ok, you have two IBQuerys attached. This should definitely work, you can
have additional parameters on the detail dataset. You have to make sure you
close the detail dataset and open it again in order for it to re-execute the
query.

I tried an example and had no problem, here's the details - so you can tell
me whether I've recreated the same conditions:

Master query:
select * from projects
order by project
Detail query
select * from project$items
where project = :project
and item$category = :cat
order by purchase$order

At design time, the IBQuerys are hooked via a datasource and the detail's
datasource property. As you can tell from the SQL, "project" is the linking
field. I've also set the :cat parameter to a valid sample value at design
time that allows me to see detail data then.

In a button click I have the following code:

IBQuery2.Close;
IBQuery2.ParamByName('cat').AsString := Edit1.Text;
IBQuery2.Open;

All works as I would expect.

If this doesn't help, post similar details of your sql and code, maybe we
can spot something.

--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"Reality is that which, when you stop believing in it, doesn't go
away." - Philip K. Dick
Back to top
Adalberto Baldini
Guest





PostPosted: Sat Feb 24, 2007 11:08 pm    Post subject: Re: TIBQuery.Params Reply with quote

Wayne Niddery [TeamB] wrote:
Quote:
Adalberto Baldini wrote:


Only
Quote:
At design time, the IBQuerys are hooked via a datasource and the detail's
datasource property. As you can tell from the SQL, "project" is the linking
field. I've also set the :cat parameter to a valid sample value at design
time that allows me to see detail data then.

In a button click I have the following code:

IBQuery2.Close;
IBQuery2.ParamByName('cat').AsString := Edit1.Text;
IBQuery2.Open;

All works as I would expect.

If this doesn't help, post similar details of your sql and code, maybe we
can spot something.


Only for test at design time try to set param project value :
select IBquery2
open param list
assign a value to :project
and save form.

In test before to click the button, move master cursor on a project
different from that you set at design time.

In my test it doesn't work.

I thought that ParamCheck set to True should clear all params before an
open. If it is not correct I will manage params clear when I construct
the form.

Thanks
Adalberto
Back to top
Bill Todd
Guest





PostPosted: Sun Feb 25, 2007 2:13 am    Post subject: Re: TIBQuery.Params Reply with quote

Adalberto Baldini wrote:

Quote:
I thought that ParamCheck set to True should clear all params before
an open. If it is not correct I will manage params clear when I
construct the form.

Parameters should only be cleared and recreated if the SQL changes.

--
Bill Todd (TeamB)
Back to top
Wayne Niddery [TeamB]
Guest





PostPosted: Sun Feb 25, 2007 11:14 pm    Post subject: Re: TIBQuery.Params Reply with quote

Adalberto Baldini wrote:
Quote:

Only for test at design time try to set param project value :
select IBquery2
open param list
assign a value to :project
and save form.

In test before to click the button, move master cursor on a project
different from that you set at design time.

In my test it doesn't work.

Ok, I can confirm this. Setting the *linking* parameter at design time seems
to mess things up (and actually worse than simply not working, it is
difficult to get it to work at all again after that without a lot of messing
around).

Quote:
I thought that ParamCheck set to True should clear all params before
an open. If it is not correct I will manage params clear when I
construct the form.

Paramcheck only tells the dataset whether it should look for and parse
parameters in the SQL statement and create parameter objects for them, it
does not do anything to those parameters after that though.

It is clearly better to leave the linking parameter alone. You can still set
other parameters at design time. However, another way around, if you really
need to set this at design time is to add a line of code (probably in
FormCreate):

IBQuery2.Params[0].Value := Unassigned;
or
IBQuery2.Params.ParamByName('project').Value := Unassigned;

You also need to close and open the query to actually get rid of the
design-time value. That seems to correct things.

--
Wayne Niddery - Winwright, Inc (www.winwright.ca)
"Reality is that which, when you stop believing in it, doesn't go
away." - Philip K. Dick
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (InterBase Express) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.