Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » run insert statement from birt(use the parameters received by birt to insert a row in my DB.)
run insert statement from birt [message #718499] Wed, 24 August 2011 14:19 Go to next message
Magg  is currently offline Magg Friend
Messages: 7
Registered: July 2011
Junior Member
Hi, I need your help. To create my reports, I included the option to save the generated file on the server side. But when the user save the file on the server, I need to register the name of the file created in the DB. I read in a forum that it is possible only implementing a servlet because birt can´t send data back to the DB. What other options i can implement for achieve this goal?? I need to save the name of the file, a description, date of creation, userId... Thanks in advance.
Re: run insert statement from birt [message #718579 is a reply to message #718499] Wed, 24 August 2011 17:21 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Magg,

Why not use a stored procedure. For example assume I have a table like:

//example my sql
CREATE TABLE `filetable` (
`filename` varchar(500) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1$$

I can then create a stored proc like:
DELIMITER $$

CREATE DEFINER=`root`@`localhost` PROCEDURE `writefilename`( IN
p_filename VARCHAR(500))
BEGIN

INSERT INTO filetable
(
filename
)
VALUES
(
p_filename
) ;

SELECT
p_filename;


END


I can then create a stored procedure dataset in BIRT that looks like:

{call writefilename(?)}

The ? will add a parameter which I can set a default value for like:

var loc
=reportContext.getHttpServletRequest().getAttribute("attributeBean").getReportDocumentName();
if( loc == null ){
loc = "No output name";
}else{
loc.substr(0,480);
}

Then drag the dataset to the report canvas and when you run the report
in the viewer the document name should be written to the db. You can
also hide the table that the stored proc is tied to.

Note that is you run in the preview mode the document name will be null.

Jason

On 8/24/2011 10:19 AM, Magg wrote:
> Hi, I need your help. To create my reports, I included the option to
> save the generated file on the server side. But when the user save the
> file on the server, I need to register the name of the file created in
> the DB. I read in a forum that it is possible only implementing a
> servlet because birt can´t send data back to the DB. What other options
> i can implement for achieve this goal?? I need to save the name of the
> file, a description, date of creation, userId... Thanks in advance.
Re: run insert statement from birt [message #718634 is a reply to message #718579] Wed, 24 August 2011 22:23 Go to previous messageGo to next message
Magg  is currently offline Magg Friend
Messages: 7
Registered: July 2011
Junior Member
Thanks, I go to try that option.

I was trying to implement a beforeRender Script.

When the file has been stored on the server, I was trying to send a servlet request from birt. The servlet save the file info on the Oracle DB.

I attach the script. can you check please? I copied the code on birt-exchange forum.

How can I send parameters correctly to my servlet?? I tested my servlet and run fine. The erros I obtain are about request var. I don´t know how to correctly build the request.

If I try to use a Store Procedure, how can I check the correct stored of the file on the folder before insert the data in the DB??

Thanks for your expert tips.
Re: run insert statement from birt [message #718636 is a reply to message #718634] Wed, 24 August 2011 22:29 Go to previous messageGo to next message
Magg  is currently offline Magg Friend
Messages: 7
Registered: July 2011
Junior Member
Yesterday, Also I made a Class that insert the data on DB, and I imported on birt, on beforerender script. I don´t obtain errors, but the info is not inserted on the DB.
Re: run insert statement from birt [message #718890 is a reply to message #718636] Thu, 25 August 2011 14:38 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you try it in the afterFactory?

Jason

On 8/24/2011 6:29 PM, Magg wrote:
> Yesterday, Also I made a Class that insert the data on DB, and I
> imported on birt, on beforerender script. I don´t obtain errors, but the
> info is not inserted on the DB.
Re: run insert statement from birt [message #719329 is a reply to message #718890] Fri, 26 August 2011 18:11 Go to previous message
Magg  is currently offline Magg Friend
Messages: 7
Registered: July 2011
Junior Member
Problem solved!! Thanks very much Jason for the tips and code, Now I know a little more about birt. Apparently i had my class duplicated in two jars with different name and in various folders. I deleted all jars, and copied only one in the lib folder of my birt site. And that works!! Best regards.
Previous Topic:Populating a report using the Report Engine API
Next Topic:Re: run insert statement from birt
Goto Forum:
  


Current Time: Thu Apr 18 16:10:54 GMT 2024

Powered by FUDForum. Page generated in 0.02298 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top