Jump to content
JasperReports Library 7.0 is now available ×

passing table names to query


2004 IR Help

Recommended Posts

By: ralamo - ralamo

passing table names to query

2005-05-17 00:21

I'm developing reports using JasperReports + iReport. When i design the layout in iReport, the query needs table name. Table name is decided at runtime. I want to pass table name as parameter. How can i do this?

 

Or is it possible to create reports completely with java code ?

 

If anyone has done that, please send the sample program. It's bit urgent. Thanks for any help.

 

 

 

 

By: macoute - macoute

RE: passing table names to query

2005-05-17 02:16

look at the "datasource" sample, it use parameter.

 

You can create template dynamicaly with all JasperDesign objects at runtime.

 

 

 

 

By: ralamo - ralamo

RE: passing table names to query

2005-05-17 04:06

Thank you for the information. I saw the example. But what exactly i want is -----

 

I want to gesign the report layout using iReport but in that i want to specify the table name dynamically based on what the user has selected in the application.

 

How can it be done? Can you pls give me the code snippet or procedure as how to do it. It will be a great help to me. Thank you.

 

 

 

 

By: Alexander Wallace - aows

RE: passing table names to query

2005-05-17 06:56

both, generating a report in pure java code and passing parameters for the query can be done... Even the whole query can be a parameter... you would do something like:

 

<parameter name="myQuery" isForPrompting="false" class="java.lang.String">

<defaultValueExpression ><![CDATA["SELECT whatever FROM whatever WHERE whatever"]]></defaultValueExpression>

</parameter>

 

and then use it as the qry for the report like:

 

<queryString><![CDATA[$P!{myQuery}]]></queryString>

 

 

 

 

 

By: macoute - macoute

RE: passing table names to query

2005-05-17 07:03

Map parameters = new HashMap();

parameters.put("TableName", "yourname");

JasperFillManager.fillReportToFile(fileName, parameters, datasource);

 

in the template:

<parameter name="TableName" class="java.lang.String"></parameter>

 

after use: $P{TableName}

 

 

 

 

By: ralamo - ralamo

RE: passing table names to query

2005-05-17 07:13

I'm still experimenting on it. Yes ... after searching quite a bit, i got one example 'noxmldesign'. That had what i wanted. But still i'm not through.

 

You both gave a good pointer to my problem. Hope i can progress further. If any problem, i will mail to the forum again.

 

Thanks again to al for the replies. It helped me.

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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...