Jump to content

Insert Query


dre-day

Recommended Posts

I cannot get  IReport to commit after an insert query. Are insert queries possible in IReport?

INSERT INTO TEMP_TABLE (BILL_ACCT_NBR, ORDER)SELECT  ltrim('$P!{temp}','and bill_acct_nbr = '),order FROM ORDERS  WHERE 1=1  $P!{order};

COMMIT

 

Link to comment
Share on other sites

  • Replies 7
  • Created
  • Last Reply

Top Posters In This Topic

 I succeeded to run insert query in a Jasperreport by running this insert query inside a stored procedure/function.

For instance you define a stored function which runs your insert query and after returns a value (no matters : logicaj, integer,...) and you can get this value in a field even if you don't care but jasper is happy and won't give an error.

It was just a test and I never used that in production.

(In fact, I wanted to update dynamically the list of recipients for a scheduled job by inserting their id in the right jasperdatabase table. But perhaps is it a little crazy ..!!)

PS: just a precision my test was running under jasperserver and I didnot use a commit statement : but the inserted values were present inside the table.



Post Edited by Gaby38 at 03/08/2011 19:36
Link to comment
Share on other sites

  • 2 weeks later...
  • 11 months later...
  • 8 years later...

Hey... there is a surprise.

Yes you cannot use insert/update queries as functionality. but you can run insert/update queries easily. you need not to put "commit" after query. The jasper will through error at the time of execution, but the query will be executed for sure. This is how I did it.

  1. I have added an addional dataset where the insert statement is written.
  2. Inserted a list/table in report pointing to the newly created dataset.
  3. Done.
  4. The jrxml will complile without any error.
  5. While execution you will get error as "Caused by: net.sf.jasperreports.engine.JRRuntimeException: net.sf.jasperreports.engine.JRException: Unable to get next record from result set." Dont worry.

PS. I have successfully done this for number of times.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...