Skip to main content



      Home
Home » Archived » BIRT » How to get Row Count of dataset through scripting
How to get Row Count of dataset through scripting [message #219093] Thu, 15 February 2007 02:33 Go to next message
Eclipse UserFriend
Hi All,

Does anyone have idea how to get row count of fetched dataset using
scripting? I tried out total.count() method in BeforeClose() method of
dataset. Is there another way to do the same and where should i put the
code? Currently I am using BIRT 2.1.0 .


Thanks in advance.

-Parimal
Re: How to get Row Count of dataset through scripting [message #219103 is a reply to message #219093] Thu, 15 February 2007 02:53 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brell.oio.de

Hi,

i don't know if there is another way, but i solved it with an extra table at
the beginning of my report. The table is bound with the dataset. I choose
table go to scripting tab and implement onCreate with i=0; Then in detail
row implement the onCreate with i++ finally set the table invisible.
It's quick and dirty i know. But is there another way??

Total.count in before Close doesnt make sense to me, does it work?


"Parimal" <parimalb@cybage.com> schrieb im Newsbeitrag
news:8d614264e3301ec63b138a852f7b1d81$1@www.eclipse.org...
> Hi All,
>
> Does anyone have idea how to get row count of fetched dataset using
> scripting? I tried out total.count() method in BeforeClose() method of
> dataset. Is there another way to do the same and where should i put the
> code? Currently I am using BIRT 2.1.0 .
>
>
> Thanks in advance.
>
> -Parimal
>
>
>
Re: How to get Row Count of dataset through scripting [message #219111 is a reply to message #219103] Thu, 15 February 2007 04:32 Go to previous messageGo to next message
Eclipse UserFriend
Hi Christian,

Thanks for your reply.

Actually I want to check whether a dataset returns data or not. If there
is no data available in the datset then I have to bind another query. Do u
have any idea how to check whether dataset is returning data or not?
I feel, Scripting need to be done inside dataset script so that another
query can be bound if no data available. What you say?

Thanks,
Parimal
Re: How to get Row Count of dataset through scripting [message #219329 is a reply to message #219111] Fri, 16 February 2007 03:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brell.oio.de

Hi,

You are correct: in dataset-scripting you should have the possibility to
change your query. But this only makes sense before the query is run. If
there s a possibility to check if query returns rows (i don't think thats
actually possible) in datascripting methods then this can only be done after
the query is run (you can't know if dataset return rows without running it
first), so that changing the query at this time should have no efect.
If in my workaround dataset returns no data then counter i will stay 0,
because detail row of your invisible table will never be created. You can
use the counter variable everywhere below this table in your report.
I create the other dataset include another table that is bound to this
dataset and set visibility to condition i=0. So this table bound to other
dataset will only be visible if first dataset returns no rows.


"Parimal" <parimalb@cybage.com> schrieb im Newsbeitrag
news:59c37d7ead8cb09532dbc73678a5fdf3$1@www.eclipse.org...
> Hi Christian,
>
> Thanks for your reply.
>
> Actually I want to check whether a dataset returns data or not. If there
> is no data available in the datset then I have to bind another query. Do u
> have any idea how to check whether dataset is returning data or not?
> I feel, Scripting need to be done inside dataset script so that another
> query can be bound if no data available. What you say?
>
> Thanks,
> Parimal
>
>
>
>
Re: How to get Row Count of dataset through scripting [message #219336 is a reply to message #219329] Fri, 16 February 2007 03:18 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: brell.oio.de

Because you can call java-code from inside RhinoScript another solution is
to write a Java helper class that runs COUNT(*)-query itself and returns
counter. Now you can call this java method in beforeOpen to check and if
necessary to modify the query.

"Christian Brell" <brell@oio.de> schrieb im Newsbeitrag
news:er3oe5$t4q$1@utils.eclipse.org...
> Hi,
>
> You are correct: in dataset-scripting you should have the possibility to
> change your query. But this only makes sense before the query is run. If
> there s a possibility to check if query returns rows (i don't think thats
> actually possible) in datascripting methods then this can only be done
after
> the query is run (you can't know if dataset return rows without running it
> first), so that changing the query at this time should have no efect.
> If in my workaround dataset returns no data then counter i will stay 0,
> because detail row of your invisible table will never be created. You can
> use the counter variable everywhere below this table in your report.
> I create the other dataset include another table that is bound to this
> dataset and set visibility to condition i=0. So this table bound to other
> dataset will only be visible if first dataset returns no rows.
>
>
> "Parimal" <parimalb@cybage.com> schrieb im Newsbeitrag
> news:59c37d7ead8cb09532dbc73678a5fdf3$1@www.eclipse.org...
> > Hi Christian,
> >
> > Thanks for your reply.
> >
> > Actually I want to check whether a dataset returns data or not. If there
> > is no data available in the datset then I have to bind another query. Do
u
> > have any idea how to check whether dataset is returning data or not?
> > I feel, Scripting need to be done inside dataset script so that another
> > query can be bound if no data available. What you say?
> >
> > Thanks,
> > Parimal
> >
> >
> >
> >
>
>
Re: How to get Row Count of dataset through scripting [message #219540 is a reply to message #219111] Fri, 16 February 2007 16:48 Go to previous message
Eclipse UserFriend
Originally posted by: johnw.innoventsolutions.com

The easiest way to do this is to create a hidden table with the
total.count() method. Then on the onRender event for the data element
containing the total.count(), assign a count variable the value. Thats
probably the easiest.

As far as assigning a query string, you can do it a few ways.

Globally, it can be done by
reportContext.getReportRunnable().getDesignInstance().getDat aSet( "dataSetName").queryText
= "";

But if you do that, you are responsible for recalling the dataset
generation, etc. I am not even sure you can do this from script.

The othehr way is from an event in the dataset, just calling
this.queryText.

What it sounds like, your best option is to use an external Java object
as your data source and use the scripted data source option. Then, you
can add in all the logic in your java code to do the switching of query
strings. So in your Java object, you use a JDBC/JNDI call to get your
data, determine if there is anything in the result set, and make another
call if necessary, then you just return.

Let me know if you need any advice on where to get info on how to do this.

John

Parimal wrote:
> Hi Christian,
>
> Thanks for your reply.
> Actually I want to check whether a dataset returns data or not. If there
> is no data available in the datset then I have to bind another query. Do
> u have any idea how to check whether dataset is returning data or not? I
> feel, Scripting need to be done inside dataset script so that another
> query can be bound if no data available. What you say?
>
> Thanks,
> Parimal
>
>
>
Previous Topic:Problem creating Stored Procedure Query Data Set on an iSeries
Next Topic:Export file in Mac computer problem
Goto Forum:
  


Current Time: Sat May 10 21:08:12 EDT 2025

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

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

Back to the top