ok, how can I pass parameters to the parameterslist??
If I want a report of only a customer passing just ID as parameter to the class.
list << "10";
orReport report( "customer", list, db );
and in my select how can I receiver this parameter??
The constructor and functions that take a QStringList of parameters is an older method that was kept for backwards compatibility. It still works but is not our recommened method. If you do use it then the Queries in report definition would reference the parameters by %1 for the first item in the list %2 for the second and so on. This is limited to a limited number of parameters and is ambigous as it relys on the order.
Instead of a QStringList you will want to use ParameterList. ParameterList is a class that is part of the OpenRPT code, in /common, and is a list of QString and QVariant Pairs. This create a name value scheme.
You could do the following:
orReport report("reportdef", params, db);
In your report definition you would use the MetaSQL functionality that is built into the renderer code to access these values. There is documentation covering this and other features of MetaSQL however here is a short example:
SELECT cust_name from cust where cust_id=<? value("cust_id");
There was a typo in my example sql. Here is the corrected version:
SELECT cust_name from cust where cust_id=<? value("cust_id") ?>;
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.