looping through dataset

Release notes for Servoy betas

looping through dataset

Postby faheemhameed » Thu Feb 03, 2005 9:30 am

Code: Select all

      var resultDisplayArr = new Array();
      var resultDS = databaseManager.getDataSetByQuery(globals.serverName, SQL, null, 10000);
        for (var i = 1 ; i <= resultDS.getMaxRowIndex() ; i++ ) {
            resultDS.rowIndex = i;
            resultDisplayArr[i] = resultDS[1];
         }
      }



In the line
resultDisplayArr[i] = resultDS[1];

resultDS[1] returns a undefined value.

In previous versions it was returning proper value from the dataset.

Thanks
Hameed
Hameed
Pilot simple software
Hong Kong
User avatar
faheemhameed
 
Posts: 763
Joined: Wed Sep 10, 2003 7:23 am

Postby patrick » Thu Feb 03, 2005 10:27 am

I also noticed some changes in datasets. It seems for example that getColumnAsArray() returns something different now. On of my methods always ran fine and since rc1 produces an error.

Could somebody explain if there has been changes and if yes, which ones?
patrick
 
Posts: 3703
Joined: Wed Jun 11, 2003 10:33 am
Location: Munich, Germany

Postby jcompagner » Thu Feb 03, 2005 12:07 pm

hameed: what does youre SQL looks like? And why aren't you use getColumnAsArray()

Patrick: What kind of error do you get now?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby IT2Be » Thu Feb 03, 2005 12:29 pm

Yep, I noticed this too. A method that ran perfectly until b3 now had to be changed...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby faheemhameed » Thu Feb 03, 2005 12:30 pm

My SQL looks like the following:

Code: Select all
         var SQL = "SELECT " + actualFieldValue + " FROM valuelist " +
                   "WHERE valuelist_name = '" + valueListName + "' " +
                   "ORDER BY " + actualFieldValue;
         var resultDS = databaseManager.getDataSetByQuery(globals.serverName, SQL, null, 10000);
         var resultDisplayArr = new Array();
         resultDisplayArr[0] = "";
         for (var i = 1; i <= resultDS.getMaxRowIndex() ; i++ ) {
            resultDS.rowIndex = i;
            resultDisplayArr[i] =  resultDS.getValue(i,1);
         }
         application.setValueListItems(valueListName, resultDisplayArr);


Now I am using

resultDisplayArr[i] = resultDS.getValue(i,1);

instead of

resultDisplayArr[i] = resultDS[1];

and it works
Hameed
Pilot simple software
Hong Kong
User avatar
faheemhameed
 
Posts: 763
Joined: Wed Sep 10, 2003 7:23 am

Postby jcompagner » Thu Feb 03, 2005 12:39 pm

found the problem. Should all work again in next release.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 8833
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Postby faheemhameed » Thu Feb 03, 2005 12:50 pm

cool! thanks!
Hameed
Pilot simple software
Hong Kong
User avatar
faheemhameed
 
Posts: 763
Joined: Wed Sep 10, 2003 7:23 am

Postby Karel Broer » Sat Apr 23, 2005 8:07 pm

I use this method, but I don't recieve data from the .getValue() function.
What's missing?
Code: Select all
var query = "SELECT tariefid, describtion, amount FROM werktijd WHERE orderid LIKE recordstatus = null " ;
var maxReturedRows = 200 ;
var dataset = databaseManager.getDataSetByQuery(currentcontroller.getServerName(), query, null, maxReturedRows);

   for(var i=1; i<= foundset.getSize(); i++)
   {
   //go to record
   var record = foundset.getRecord(i);

   //create new record and insert found record data
   forms.testform.controller.newRecord();
   forms.testform.factuurid = factuurid ;
   forms.testform.controller.codeid = dataset.getValue(i,1);
   forms.testform.controller.describtion = dataset.getValue(i,2);
   forms.testform.controller.amount = dataset.getValue(i,3);
   
   //set status on passive
   forms.DEV_werktijd.recordstatus = '2';
   }
Karel Broer
ServoyCamp - http://www.servoycamp.com
User avatar
Karel Broer
 
Posts: 779
Joined: Mon May 03, 2004 12:49 am
Location: Doetinchem

Postby IT2Be » Sun Apr 24, 2005 12:11 am

Karel,

What are you doing here? I really don't understand...

It looks like you are mixing a foundset and a dataset or do I misinterpret you code?

Is your currentcontroller really the controller you want (the main form)?

Do you have a column 'describtion' or 'description'? In other words is there a(ny) misspelling in your query?

The field reference 'forms.testform.controller.xxx' is wrong. It should be 'forms.testform.xxx' without the controller...
Marcel J.G. Trapman (IT2BE)
SAN partner - Freelance Java and Servoy
Servoy Components - IT2BE Plug-ins and Beans for Servoy
ServoyForge - Open Source Components for Servoy
User avatar
IT2Be
Servoy Expert
 
Posts: 4766
Joined: Tue Oct 14, 2003 7:09 pm
Location: Germany

Postby maarten » Sun Apr 24, 2005 10:26 am

TIP: (can't stress enough)..use code completion!
Might feel a bit clumsy at first but if you stick to it,
it beats typing stuff out yourself AND rules out syntax errors
1) type "f"
2) type Ctrl+Spacebar.. etc...
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Postby Karel Broer » Sun Apr 24, 2005 11:17 pm

IT2BE wrote:Karel,

What are you doing here? I really don't understand...
It looks like you are mixing a foundset and a dataset or do I misinterpret you code?


Hi Marcel! Purpose of this method is to copy data from a foundset into new records in another table. This all happens in a loop.

Is your currentcontroller really the controller you want (the main form)?


The main form that contains the method is called 'orderdetail'. What I do search all the timesheet records (from the selected order) in the table 'werktijd' by a query. After that I copy each found record into the invoice table called 'factuurregels' by a loop. It's a kind of sync method, but then a one way direction.

Do you have a column 'describtion' or 'description'? In other words is there a(ny) misspelling in your query?


I just translated the method (too quick) to clarify it a bit. Made a translation misspelling... sorry for that! :wink:

The field reference 'forms.testform.controller.xxx' is wrong. It should be 'forms.testform.xxx' without the controller...


Thanks! That solves a lot! What I still don't get is why not all of the data from the newly made records is copied.. could it be a refresh option?
Karel Broer
ServoyCamp - http://www.servoycamp.com
User avatar
Karel Broer
 
Posts: 779
Joined: Mon May 03, 2004 12:49 am
Location: Doetinchem


Return to Latest Releases

Who is online

Users browsing this forum: No registered users and 28 guests