run insert statement from birt [message #718499] |
Wed, 24 August 2011 10:19  |
Eclipse User |
|
|
|
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 13:21   |
Eclipse User |
|
|
|
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 #719329 is a reply to message #718890] |
Fri, 26 August 2011 14:11  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 1.33807 seconds