merge datasets

Questions, tips and tricks and techniques for scripting in Servoy

merge datasets

Postby Hans Nieuwenhuis » Sat Nov 05, 2011 12:27 pm

Hi,

Is it possible to merge datasets.
I have datasets from several getDataSetByQuery runs ( can not be done in 1 query )
and I want to merge those datasets to display them in a form.

Regards,
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: merge datasets

Postby Hans Nieuwenhuis » Sat Nov 05, 2011 12:57 pm

I found a way to do this by using addRow.

By using
Code: Select all
      for (var j = 1; j <= _dataset.getMaxRowIndex(); j++) {
               _totalDataset.addRow(_dataset.getRowAsArray(j))
      }
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands

Re: merge datasets

Postby ROCLASI » Sat Nov 05, 2011 5:46 pm

Hi Hans,

To make this more memory efficient I would use the following code:

Code: Select all
for (var j = 1; j <= _dataset.getMaxRowIndex(); j++) {
    _totalDataset.addRow(_dataset.getRowAsArray(1));
    _dataset.removeRow(1);
}


Unless of course you need to keep the original DataSet intact.

Hope this helps.
Robert Ivens
SAN Developer / Servoy Valued Professional / Servoy Certified Developer

ROCLASI Software Solutions / JBS Group, Partner
Twitter: @roclasi
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5342
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: merge datasets

Postby Hans Nieuwenhuis » Sat Nov 05, 2011 5:51 pm

Right !, Thanks
Hans Nieuwenhuis
Betagraphics
http://www.deltics.nl
http://www.betagraphics.nl

Servoy Version 7.3.1
Java version 1.7.0.x
Database Oracle 11g
User avatar
Hans Nieuwenhuis
 
Posts: 1026
Joined: Thu Apr 12, 2007 12:36 pm
Location: Hengelo, The Netherlands


Return to Methods

Who is online

Users browsing this forum: No registered users and 3 guests

cron