Master-Detail relationship for large detail tables
Hi,
I'm developing a generical report generator. The report receives a dataset for its creation. In my case, I need to create a master-detail N:N relationship to represent the data.
In this link, there's an master-detail example which fills a dataset using SQL:
http://documentation.devexpress.com/#Windo...omDocument11225
What I want is similar, but my master SQL has some filter criteria, such as:
"SELECT CategoryID, CategoryName, Picture FROM Categories WHERE CategoryName LIKE '%Beverages%'".
Using the following detail SQL would be unfeasible, because I may have large detail tables:
"SELECT CategoryID, ProductID, ProductName, UnitPrice FROM Products"
Worrying about performance issues, detail SQL must return only the respective products of the selected categories.
How can I achieve this?
I'm developing a generical report generator. The report receives a dataset for its creation. In my case, I need to create a master-detail N:N relationship to represent the data.
In this link, there's an master-detail example which fills a dataset using SQL:
http://documentation.devexpress.com/#Windo...omDocument11225
What I want is similar, but my master SQL has some filter criteria, such as:
"SELECT CategoryID, CategoryName, Picture FROM Categories WHERE CategoryName LIKE '%Beverages%'".
Using the following detail SQL would be unfeasible, because I may have large detail tables:
"SELECT CategoryID, ProductID, ProductName, UnitPrice FROM Products"
Worrying about performance issues, detail SQL must return only the respective products of the selected categories.
How can I achieve this?
Comments
You have several options:
1) add the filter criteria to the detail sql too.
2) add parameter to the detail sql and bind the parameter's value to the master:
SELECT CategoryID, ProductID, ProductName, UnitPrice FROM Products WHERE CategoryID = @param1
@param1 will be defined as follows:
Name = param1
DataType = Int32
DefaultValue = 0
Expression = [master_table.CategoryID]
Solution number 2 is exactly what I need, but I'm affraid I didn't let some information clear: I use C# and Firebird database. And I don't see how to implement your solution using that.
Thanks for your time!
Any other ideas?!
Another option is to create datasources in the report using the "Data|Add data source" menu. In this case you can control how the detail datasource is filled. Note that you may pass user-generated sql to the report datasource:
(report.GetDataSource("the_master_datasource") as TableDataSource).SelectCommand = "select * from ...";
I am trying to use the option 2 as you described above to print a Master-Detail report using a database (SQL Anywhere 16).
However, it prints only the *first* Master record with it Details records. When I right click at the Master data source I see several records, all the Offers do have rows in the database.
I have attached a simplified example of my report.
It contains a table Offers and Details. In the Offers the Select statement is (nummer is the ID):
SELECT * FROM offertes WHERE nummer BETWEEN 979030 AND 979040 ORDER BY nummer DESC;
The Detail contains this Select statement:
SELECT * FROM offerteregels WHERE offerte = :offerte_nummer;
And the Detail has a parameter named 'offerte_nummer' with the expression '[Offertes.nummer]
What do I am wrong..?
Tia
Hans
Ignore my post please.