Otto Hahn Posted February 15, 2016 Posted February 15, 2016 How to change the database and table names in a report or subreport in my code?Examples:SELECT DISTINCT "DB20154"."REGISTER_TABLE"."VAL_FFIELD"FROM "DB20154"."REGISTER_TABLE"[/code]change toSELECT DISTINCT "DB20116"."REGISTER_TABLE"."VAL_FFIELD"FROM "DB20116"."REGISTER_TABLE"[/code]orSELECT DISTINCT "DB_DEVELOPER"."T_123456789"."VAL_FFIELD"FROM "DB_DEVELOPER"."T_123456789"[/code] SELECT DISTINCT "DB_CUSTOMER"."T_163258984"."VAL_FFIELD"FROM "DB_CUSTOMER"."T_163258984"[/code]
kkriplani Posted February 15, 2016 Posted February 15, 2016 There could be a mian query which can be changed using the db sign on top or look for the dataset name and change the query.I suggest you go through the Document provided to you along with the setup.Regards,KKriplani
Otto Hahn Posted February 15, 2016 Author Posted February 15, 2016 JasperReport jasperReport = JasperCompileManager.compileReport(reportFilePath.getAbsolutePath());JRDataset dataset = jasperReport.getMainDataset();JRQuery query = dataset.getQuery();for (JRQueryChunk chunk : query.getChunks()) { System.out.println(chunk.getText());}[/code]In this context it's not possible to change anything.My goal only would be to replace the db- and the tablenanme.
hozawa Posted February 15, 2016 Posted February 15, 2016 Just use "$P! " in your report and pass the sql statement as your parameter.
Solution Otto Hahn Posted February 16, 2016 Author Solution Posted February 16, 2016 Thank you hozawa,change fromSELECT DISTINCT "DB_DEVELOPER"."T_123456789"."VAL_FFIELD"FROM "DB_DEVELOPER"."T_123456789"[/code]toSELECT DISTINCT VAL_FFIELDFROM "$P!{DB}"."$P!{TABLE}"[/code]The SQL statement now is dynamic. http://community.jaspersoft.com/sites/all/libraries/ckeditor/plugins/smiley/images/thumbs_up.gif
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now