Passing Parameters to SQL
Passing Parameters to SQL
Hello Stimulsoft,
I am working on my own Report to Pdf exporter and I want to pass parameters with Java to get a query for my report, so the report can show me the data, my Select command are in php working with a Restful webservice.
Do I have to set something in the designer in the dictionary to pass the parameter to the sql command or do I pass the parameter directly to the sql command?
I have found this:
report.getDictionary().getVariables().get(var).setValue(val);
report.getVariables().put(var, val);
but I dont understand how to use it to pass parameters to sql.
Thank you
best regards
Loki
I am working on my own Report to Pdf exporter and I want to pass parameters with Java to get a query for my report, so the report can show me the data, my Select command are in php working with a Restful webservice.
Do I have to set something in the designer in the dictionary to pass the parameter to the sql command or do I pass the parameter directly to the sql command?
I have found this:
report.getDictionary().getVariables().get(var).setValue(val);
report.getVariables().put(var, val);
but I dont understand how to use it to pass parameters to sql.
Thank you
best regards
Loki
Re: Passing Parameters to SQL
Hello.
For example you can define Variable1 <int> & then your sql string may look like: select * from actor where actor_id = {Variable1}
For example you can define Variable1 <int> & then your sql string may look like: select * from actor where actor_id = {Variable1}
Re: Passing Parameters to SQL
Hello.
If my sql string is looking like this:
"select* from actor where actor_id = @variable1"
and in Java I am getting the value of my jtextfield in the gui and use this code:
report.getDictionary().getVariables().get("@variable1").setValue(val);
report.getVariables().put("@variable1", val);
do I need to define this variable in the dictionary or can I pass the value directly from the code to the sql string???
If my sql string is looking like this:
"select* from actor where actor_id = @variable1"
and in Java I am getting the value of my jtextfield in the gui and use this code:
report.getDictionary().getVariables().get("@variable1").setValue(val);
report.getVariables().put("@variable1", val);
do I need to define this variable in the dictionary or can I pass the value directly from the code to the sql string???
Re: Passing Parameters to SQL
Hello.
You must use variables in {} not use @-symbol.
If you not define this variable in the dictionary you must put it by code, lilke:
report.getDictionary().getVariables().add(new StiVariable("variable1", 1));
You must use variables in {} not use @-symbol.
If you not define this variable in the dictionary you must put it by code, lilke:
report.getDictionary().getVariables().add(new StiVariable("variable1", 1));
Re: Passing Parameters to SQL
Hello,
is there a way in code to retrieve the path to the json data from the report object and change the path??
is there a way in code to retrieve the path to the json data from the report object and change the path??
Re: Passing Parameters to SQL
Hello.
You can do like this:
You can do like this:
Code: Select all
((StiJsonDatabase) report.getDictionary().getDatabases().get(0)).setPathData("/data.json");
Re: Passing Parameters to SQL
Hello.
Thank you, getPathData is working, with System.out.print I see the Path of my Json database, but it shows me a warning:
Feb 10, 2016 9:00:05 AM com.stimulsoft.report.engine.parser.StiParser ParseTextValue
WARNUNG: Parser error: The name '%s' does not exist in the current context, FHBill, , ,
and setPathData is not working, it shows me the same warning, do I have to do something with the dictionary or the dataSource after I set the Path??
Thank you, getPathData is working, with System.out.print I see the Path of my Json database, but it shows me a warning:
Feb 10, 2016 9:00:05 AM com.stimulsoft.report.engine.parser.StiParser ParseTextValue
WARNUNG: Parser error: The name '%s' does not exist in the current context, FHBill, , ,
and setPathData is not working, it shows me the same warning, do I have to do something with the dictionary or the dataSource after I set the Path??
Re: Passing Parameters to SQL
It's working now without the warning, and the setDataPath method is working, too.
Thank you.
Thank you.
Re: Passing Parameters to SQL
Hello.
Thank you for informing us about your issue.
We are always glad to help you.
Thank you.
Thank you for informing us about your issue.
We are always glad to help you.
Thank you.
-
- Posts: 22
- Joined: Wed Apr 01, 2015 2:29 pm
Re: Passing Parameters to SQL
Hi,
I've used the code below to add variable to dictionary:
report.getDictionary().getVariables().add(new StiVariable("variable1"));
but it adds category to flex designer and not a variable.
I've used the code below to add variable to dictionary:
report.getDictionary().getVariables().add(new StiVariable("variable1"));
but it adds category to flex designer and not a variable.