Cosmin Prund wrote:
> I've got no idea how to use TIbDataSet for any purpose but I can show 
> you how to use TIbQuery to do this. Besides, TIbQuery is probably your 
> best option any way since it allows you to put in sn SQL query that will 
> run against the server.
>
> (1) You set up your "Master" data set. I'm making no assumptions about 
> your Master dataset, except that it is a TDataSet descendent (this 
> includes TIbQuery, TIbDataSet, TBDETable - and many many others). Make 
> sure your "Master" data set includes the fields you want to use to 
> filter your "Client" data set.
> (2) Put a TDataSource on your form/data module and link it to your 
> Master DataSet.
> (3) Put a TIbQuery on your form/data module, link it to your TIbDatabase 
> and your TIbTransaction. Link it's DataSource property to the 
> TDataSource at (2).
> (4) In your TIbQuery.SQL put an SQL statement that returns the fields 
> your are interested in and makes use of the fields in the "Master" data set.
>
> Ex: If you have a CLIENTS table and an ORDERS table, and the ORDERS 
> tables has an ID_CLIENT field, after you made sure the Master dataset 
> includes the ID_CLIENT field, you can put something like this in the 
> "Detail" dataset's SQL statement: "SELECT * FROM ORDERS WHERE 
> ID_CLIENT=:ID_CLIENT". Your statement may be as complex as you need it 
> to be. The "Detail" dataset will pe "refreshed" every time the row in 
> the "Master" dataset is changed.
>   

The important thing to note is this part:

    ID_CLIENT = :ID_CLIENT

What this means is that the one with the colon (:) in front is a 
parameter.  If this second query has a value provided for it's 
DataSource property, it will try to obtain the value for that parameter 
from the datasource.  As and when that parameter changes, it will 
re-execute the query with the new value, so you are continually being 
shown the correct client records for the record the master dataset is 
currently positioned at.

This is the part that often confuses people, because they don't quite 
understand what the parameter is, or how it is filled for you 
automatically by Delphi, if the DataSource has been provided.  :)


Kind regards,


Scott :)
_______________________________________________
Delphi-DB mailing list
Delphi-DB@elists.org
http://www.elists.org/mailman/listinfo/delphi-db

Reply via email to