How can I pass mysql query fields to ireport?

1

When making an sql query the fields vary and I do not know how I can do so that ireport shows me those fields with their data when I run it. Axis: Query 1: SELECT col1, col2, col3 FROM table; but the report can also receive this other query SELECT col4, col5, col6 FROM table. How to make the ireport load the columns of the query sql

thanks.

    
asked by Germán 13.07.2017 в 19:19
source

2 answers

1

ANSWER: What I did was put parameters in the columns and put an alias in the query. Ex: SELECT $ P! {Column} AS Column, $P!{fecha1} AS date1, $P!{fecha2} AS date2, $P!{fecha3} AS date3, $P!{fecha4} AS date4, $P!{fecha5} AS date5 FROM $ P! {Table};

The "fields" part of the left of the Ireport creates the fields of each parameter: Column, date1, date2 ... date5.

On the report sheet, just assign the fields to the respective textfields. I started the report, put the values of the parameters and that's it.

I hope it helps you. = D

    
answered by 14.07.2017 в 15:35
0

You should just apply parameters in ireport, which can be created from the same interface and type what you need, then in your query call as $P{parametro}

    
answered by 13.07.2017 в 19:36