How do I use multiple parameters in BITR? [message #46236] |
Wed, 15 June 2005 06:47  |
Eclipse User |
|
|
|
Originally posted by: myggen.gmail.com
Lets say I have a company table, and I want the user to specify which
company to shown in the report. I add a report parameter, and the user can
enter a company id. Simple! But what if the user wants to enter an unknown
number of company ids? I have a query that looks something like this:
SELECT * FROM company
WHERE comp_id IN (?)
I have a report parameter called companyID. It works fine if I enter a
single comp_id. But I havent found any way to send a list of numbers. For
example, a comma separated list (100, 101, 102) gives the following error:
There are errors on the report page:
Error1:Cannot execute the statement.
Can this be done? Are there any other ways to achieve the same goal?
Thanks,
Eirik
|
|
|
Re: How do I use multiple parameters in BITR? [message #46295 is a reply to message #46236] |
Wed, 15 June 2005 07:44   |
Eclipse User |
|
|
|
Originally posted by: juergen.schwarz.gefasoft.de
Eirik Hansen schrieb:
> Let�s say I have a company table, and I want the user to specify which
> company to shown in the report. I add a report parameter, and the user
> can enter a company id. Simple! But what if the user wants to enter an
> unknown number of company ids? I have a query that looks something like
> this:
>
> SELECT * FROM company
> WHERE comp_id IN (?)
>
> I have a report parameter called companyID. It works fine if I enter a
> single comp_id. But I haven�t found any way to send a list of numbers.
> For example, a comma separated list (100, 101, 102) gives the following
> error:
>
> �There are errors on the report page: Error1:Cannot execute the
> statement. �
>
> Can this be done? Are there any other ways to achieve the same goal?
> Thanks,
> Eirik
Well , if the number of parameters is always the same, you can just
change your SQL statement like (for 3 parameters):
SELECT * FROM company WHERE comp_id IN (?,?,?)
If the number of parameters is variable, you have to do it another way,
which I don't know at the moment ;-)
>
|
|
|
|
|
|
|
|
|
|
|
Re: How do I use multiple parameters in BITR? [message #50530 is a reply to message #47397] |
Thu, 23 June 2005 12:08   |
Eclipse User |
|
|
|
Originally posted by: dsdas.yahoo.com
How I pass the variable 'queryText' to dataSet??
"Gary Xue" <gxue@actuate.com> escreveu na mensagem
news:d8smn5$qhu$1@news.eclipse.org...
> Eirik,
> You can't pass a list of values to this query using SQL parameters:
> SELECT * FROM compnay WHERE comp_id IN (?)
> This seems to be a limitation of SQL / JDBC rather than BIRT. In the 2 DB
> platforms that I tested (SQL Server, Oracle), JDBC driver identifies the
> single parameter as Integer type. This means that you can only pass a
> single
> integer value to this SQL query. It does not accept an array. (If someone
> on
> this newsgroup knows for sure whether you can pass a Java array as a SQL
> input parameter please share it with me - greatly appreciated).
>
> However you can use BIRT Scripting to compose a dynamic SQL to achieve
> what
> you want to do. Use the BIRT code editor to edit the "preOpen" method of
> you
> data set, and type in something like this:
>
> var valueList = " (100, 101, 102) "; // This list can be
> created
> dynamically based on user input
>
> // The next line alters the SQL query of the data set at runtime
> queryText = "SELECT * FROM company WHERE comp_id IN " + valueList;
>
> Try this out and let me know if this works for you.
>
> Gary Xue
> BIRT Committer
>
>
>
> "Eirik Hansen" <myggen@gmail.com> wrote in message
> news:ad04187074c6af9e4e5df065daed5157$1@www.eclipse.org...
>> Let's say I have a company table, and I want the user to specify which
>> company to shown in the report. I add a report parameter, and the user
>> can
>> enter a company id. Simple! But what if the user wants to enter an
>> unknown
>> number of company ids? I have a query that looks something like this:
>>
>> SELECT * FROM company
>> WHERE comp_id IN (?)
>>
>> I have a report parameter called companyID. It works fine if I enter a
>> single comp_id. But I haven't found any way to send a list of numbers.
>> For
>> example, a comma separated list (100, 101, 102) gives the following
>> error:
>>
>> "There are errors on the report page:
>> Error1:Cannot execute the statement. "
>>
>> Can this be done? Are there any other ways to achieve the same goal?
>>
>> Thanks,
>> Eirik
>>
>>
>>
>
>
|
|
|
Re: How do I use multiple parameters in BITR? [message #50827 is a reply to message #50530] |
Thu, 23 June 2005 16:03  |
Eclipse User |
|
|
|
queryText is not a variable. It's a property of the runtime DataSet
Javascript object. The "preOpen" script of a data set is executed using the
DataSet object as its scope (i.e., preOpen is executed as if it's a method
of the DataSet object), therefore within this scope you can directly use
"queryText" to refer to the property. "this.queryText" also works and has a
clearer semantic.
Gary
"Daniel" <dsdas@yahoo.com> wrote in message
news:d9emld$sjd$1@news.eclipse.org...
> How I pass the variable 'queryText' to dataSet??
>
> "Gary Xue" <gxue@actuate.com> escreveu na mensagem
> news:d8smn5$qhu$1@news.eclipse.org...
> > Eirik,
> > You can't pass a list of values to this query using SQL parameters:
> > SELECT * FROM compnay WHERE comp_id IN (?)
> > This seems to be a limitation of SQL / JDBC rather than BIRT. In the 2
DB
> > platforms that I tested (SQL Server, Oracle), JDBC driver identifies the
> > single parameter as Integer type. This means that you can only pass a
> > single
> > integer value to this SQL query. It does not accept an array. (If
someone
> > on
> > this newsgroup knows for sure whether you can pass a Java array as a SQL
> > input parameter please share it with me - greatly appreciated).
> >
> > However you can use BIRT Scripting to compose a dynamic SQL to achieve
> > what
> > you want to do. Use the BIRT code editor to edit the "preOpen" method of
> > you
> > data set, and type in something like this:
> >
> > var valueList = " (100, 101, 102) "; // This list can be
> > created
> > dynamically based on user input
> >
> > // The next line alters the SQL query of the data set at runtime
> > queryText = "SELECT * FROM company WHERE comp_id IN " + valueList;
> >
> > Try this out and let me know if this works for you.
> >
> > Gary Xue
> > BIRT Committer
> >
> >
> >
> > "Eirik Hansen" <myggen@gmail.com> wrote in message
> > news:ad04187074c6af9e4e5df065daed5157$1@www.eclipse.org...
> >> Let's say I have a company table, and I want the user to specify which
> >> company to shown in the report. I add a report parameter, and the user
> >> can
> >> enter a company id. Simple! But what if the user wants to enter an
> >> unknown
> >> number of company ids? I have a query that looks something like this:
> >>
> >> SELECT * FROM company
> >> WHERE comp_id IN (?)
> >>
> >> I have a report parameter called companyID. It works fine if I enter a
> >> single comp_id. But I haven't found any way to send a list of numbers.
> >> For
> >> example, a comma separated list (100, 101, 102) gives the following
> >> error:
> >>
> >> "There are errors on the report page:
> >> Error1:Cannot execute the statement. "
> >>
> >> Can this be done? Are there any other ways to achieve the same goal?
> >>
> >> Thanks,
> >> Eirik
> >>
> >>
> >>
> >
> >
>
>
|
|
|
Powered by
FUDForum. Page generated in 0.08266 seconds