andrew_50 Posted May 22, 2018 Share Posted May 22, 2018 I have a report which is to be run several times a day, but I do not want the data from an earlier run to be printed in a later run.I've got a field which I can use as a flag, but I don't see how to set it after a run of the report.I am wondering if I can include a direct call to a stored procedure as part of the report, but am not sure how I'd do this. Link to comment Share on other sites More sharing options...
reportdev Posted May 22, 2018 Share Posted May 22, 2018 If you are using Oracle / SQL Server. try writing a procedure which will update the records in the database. This is done using plsql datasource on jasper. https://community.jaspersoft.com/questions/1076991/generate-unique-document-numberAbove post has a jrxml in it... I believe you are basically trying to do the same thing. Link to comment Share on other sites More sharing options...
riodavid Posted May 23, 2018 Share Posted May 23, 2018 Jasper can't write to the database. You can use stored procedure. Just write "EXEC stored_procedure_name" in the Dataset and Query Dialog window. Link to comment Share on other sites More sharing options...
andrew_50 Posted May 23, 2018 Author Share Posted May 23, 2018 RioDavid.Is there an example of how to call a stored procedure? I'm fairly much a newbie.That and I'd like it (the stored procedure) to be run as part of a report run. Is that implied in your answer? Link to comment Share on other sites More sharing options...
reportdev Posted May 23, 2018 Share Posted May 23, 2018 did you check this post ? https://community.jaspersoft.com/questions/1076991/generate-unique-document-number Link to comment Share on other sites More sharing options...
andrew_50 Posted May 23, 2018 Author Share Posted May 23, 2018 I had seen that, but... it didn't look too helpfulPretty sure a sequence is not what I'm after. I am using mysql, and I want to flag the records selected for the report as printed (by the time the report is done).Further to your links, which I thank you for. Can scriplets be used to update a database? Also, they seem to need to be set up in jasperStudio, but I'm not sure how to write any ccode for them? Link to comment Share on other sites More sharing options...
riodavid Posted May 24, 2018 Share Posted May 24, 2018 Hi Andrew, this is how we roll. Link to comment Share on other sites More sharing options...
andrew_50 Posted May 24, 2018 Author Share Posted May 24, 2018 riodavid, I tried that earlier.However, as indicated with the little red "x" on your scrrenshot, studio is going to generate an error.This is what it did when I tried it. So... still battling with this.Thanks all for the help! Link to comment Share on other sites More sharing options...
reportdev Posted May 24, 2018 Share Posted May 24, 2018 @andrew_50 you either need to know how to write a stored procedure or a java scriptlet.both the implementations perform the same output. I would suggest you should think about writing a mysql procedure first and then implement it in jasper.try writing a mysql procedure which should output a cursor and this cursor can be used for displaying the report.inside the same procedure, you should update the records that have been fetched by the cursor. Link to comment Share on other sites More sharing options...
riodavid Posted May 25, 2018 Share Posted May 25, 2018 First you should use some real parameters, in my screenshot for example, you should use:exec dbo.myStoredProcedure '2017/01/01', '2017/02/02'[/code]Then click "Read Fields" to get the actual fields. When fields are loaded, you can replace the real parameters to $P expressions. Link to comment Share on other sites More sharing options...
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