Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Insert data into audit table from data set
mzeevalk
We are currently using BIRT 2.6.1 and we are attempting to insert data into a audit table that includes data from the result set from the report's main data set. I added the following (which I found on another online resource) to the onFetch script (I also tried the afterOpen script) of the data set we need to capture data from:
myTxn = MXReportTxnProvider.create(this.getDataSource().getName());
myStmt = myTxn.createStatment();
myStmt.setQuery("INSERT INTO TMP_BIRT_TEST VALUES ("+params["rp_rpt_yr"].value+", '"+row["DATA_SET_RESULT_1"]+"') ");
myTxn.save();
Am I using the incorrect transaction provider or do I need to import additional libraries to get this to work or is there a simpler way to do this? I tried commenting out all but the first line and still see an error so I'm thinking there is a library issue.
Find more posts tagged with
Comments
mwilliams
Ok, so you already have the dataSet created and you want to take data from it and put it into a table? Why not just bind the dataSet to the table? Maybe I'm missing something? Is the audit table bound to another dataSet?
mzeevalk
Sorry, by table I meant just a database table not a physical table with the BIRT report. Essentially everytime a BIRT report runs we need to log the data returned from the main data set to an audit table within the database. So if a BIRT report is passed parameters and 10 rows are returned (meaning 10 reports are generated) there should be 10 records inserted into this database table.
mwilliams
I see. I've not done any database write back, but here is a devShare post that might help you out:
http://www.birt-exchange.org/org/devshare/designing-birt-reports/717-birt-report-with-database-writeback/
mzeevalk
Thanks Michael, this makes sense, but I am surprised this can't be done within the onFetch event of the data set. If anyone on this forum knows of a way to write SQL insert statements to be executed upon retrieving data from a data set, please let me know.