Normal Topic Looking to Simplify Repeated ResultSet Search (Read 747 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Looking to Simplify Repeated ResultSet Search
Feb 20th, 2014 at 1:29am
Print Post Print Post  
Hi all,

I'm looking to build a dashboard screen that will show my staff's stats, and refresh every so often.  However, in building my test screen, I'm already seeing a huge drain on resources through pulling multiple XResultSetSearches.

Here's my code for just one staff member below.  If I go along this path, I'll be running about 60 XResultSet searches every refresh. 

Does anyone have any ideas on how I could streamline this, before I develop the report much further?

Thanks!


Code
Select All
#include "sbasic_include.sbas"

var vButtonOn as int

var vRSHandle as int
var vNoOfRecords as int
var vLoop as int
var vMTDRange as string
var vPDCRange as string

vMTDRange = MonthStart + ".." + @serverdate()
vPDCRange = (@serverdate()+1) + ".." + MonthEnd

if rCol1 <>""
{
	rColName1 = @xlookup(@FN, rCol1,"Staff Screen!StaffRef", "StaffName")
	rColDaily1 = rColTarget1 / Days

	// ===============
	// Figure Out MTD
	// ===============

	vRSHandle = @XResultSetSearch(@FN, "Debtors!Payments", 0, 2, "!PmtColl=" + rCol1, "!PmtDate=" + vMTDRange)

	if(vRSHandle > -1)
	{
		rColMTD1 = 0

		vNoOfRecords = @XResultSetTotal(vRSHandle)
		for vLoop = 1 to vNoOfRecords
			XResultSetCurrentPosition(vRSHandle, vLoop)
			rColMTD1 = rColMTD1 + @tomoney(@XResultSetValue(vRSHandle, "PmtComHere")) + @tomoney(@XResultSetValue(vRSHandle, "PmtComDir"))
		next
		XResultSetClose(vRSHandle)
	}

	// ===============
	// Figure Out PDC
	// ===============

	vRSHandle = @XResultSetSearch(@FN, "Debtors!Payments", 0, 2, "!PmtColl=" + rCol1, "!PmtDate=" + vPDCrange)

	if(vRSHandle > -1)
	{
		rColPDC1 = 0

		vNoOfRecords = @XResultSetTotal(vRSHandle)
		for vLoop = 1 to vNoOfRecords
			XResultSetCurrentPosition(vRSHandle, vLoop)
			rColPDC1 = rColPDC1 + @tomoney(@XResultSetValue(vRSHandle, "PmtComHere")) + @tomoney(@XResultSetValue(vRSHandle, "PmtComDir"))
		next
		XResultSetClose(vRSHandle)
	}

}
 

  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Looking to Simplify Repeated ResultSet Search
Reply #1 - Feb 20th, 2014 at 3:16pm
Print Post Print Post  
Hello Blair,

When you say 60 XResultSetSearches is that 60 from 1 Sesame client or 2 each from 30 different Sesame clients?

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: Looking to Simplify Repeated ResultSet Search
Reply #2 - Feb 21st, 2014 at 4:10am
Print Post Print Post  
Hi Ray,

Basically it would be 60 repeated XResultSet searches from the same database to populate a form to appear as a report or table.  So one client, pulling from one database.  I'm sure there's a better way to do this.

My plan (currently) is to build a form to populate and refresh every 5 minutes, and then put it up as a dashboard on a largescreen monitor in the office.  Assuming I don't bog out our database with this report ...
  
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2482
Joined: Aug 20th, 2003
Re: Looking to Simplify Repeated ResultSet Search
Reply #3 - Feb 21st, 2014 at 5:00pm
Print Post Print Post  
Hello Blair,

You can cut it down to 2 XResultSetSearch() commands, one for PmtDate=" + vMTDRange and the other for PmtDate=" + vPDCrange then when looping through the records store the totals of PmtComHere and PmtComDir in a 3 by 30 array, with the [2,1-30] range being for the vMTDRange and the [3,1-30] range being for the vPDCRange. The [1,1-30] range is for the Staff Ref ID so you know where in the array to put the values from the records as you are looping through them.

-Ray
  

Raymond Yoxall Consulting
ray.yoxall@gmail.com
ryoxall@lantica.com
Sesame Applications, Design and Support
Back to top
IP Logged