Normal Topic XResultSetSearch ranges (Read 2338 times)
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
XResultSetSearch ranges
Jun 22nd, 2013 at 4:52pm
Print Post Print Post  
Hi all,

Here's my next stumbling block in building my stair step report ... I need to use XResultSetSearch to pull values so I can create a total amount of inventory listed in any given month.

Here's my current code (which returns 0 -- not the answer I want):

Code
Select All
vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBListed=" + vListStart + ".." + vListEnd, "!DBCltNo="+CltString)
 



I've tried fiddling with > and < in the formula, and that didn't work either ... help?
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XResultSetSearch ranges
Reply #1 - Jun 22nd, 2013 at 5:47pm
Print Post Print Post  
Are you saying that vRSHandle is zero, or that in code not shown, you are checking the number of records in the result set and there are zero records?

The handle returned from @XResultSetSearch needs to checked against -1 - indicating an error.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: XResultSetSearch ranges
Reply #2 - Jun 22nd, 2013 at 6:16pm
Print Post Print Post  
Hi there sir ... here's the code from the whole report cell ... the commented vResultSetSearches are my failed attempts ...

Code
Select All
#include "sbasic_include.sbas"

var vListStart as date
var vListEnd as date
var vRSHandle as int
var vNoOfRecords as int
var vLoop as int

vListStart = (@Str(@Year(ListMo2) + "-" + (@Str(@month(ListMo2))) + "=" + "01"))
vListEnd = vListStart + 31
vListEnd = (@Str(@Year(vListStart) + "-" + (@Str(@month(vListStart))) + "=" + "01"))

// vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBListed=">=vListStart, "!DBListed="<=vListEnd, "!DBCltNo="+CltString)
// vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBListed=" + vListStart + ".." + vListEnd, "!DBCltNo="+CltString)
// *** CALCS ALL INVENTORY *** vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBCltNo="+CltString)
vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBListed=" + vListStart + "..", "!DBListed=" + ".." +vListEnd, "!DBCltNo=" + CltString)


if(vRSHandle > -1)
{
	ListedString = 0
	vNoOfRecords = @XResultSetTotal(vRSHandle)
	for vLoop = 1 to vNoOfRecords
		XResultSetCurrentPosition(vRSHandle, vLoop)
		ListedString = @Appendstringarray(ListedString, @XResultSetValue(vRSHandle, "DBList"))
		next
	XResultSetClose(vRSHandle)
}

ListedString = @sumlistvalues(ListedString)

 

  
Back to top
IP Logged
 
Bharat_Naik
Senior Member
Members
*****
Offline


Ever ready to learn and
share

Posts: 1202
Location: Chicago,  Illinois
Joined: Dec 16th, 2003
Re: XResultSetSearch ranges
Reply #3 - Jun 22nd, 2013 at 6:28pm
Print Post Print Post  
// vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBListed=">=vListStart, "!DBListed="<=vListEnd, "!DBCltNo="+CltString)

Please see if the code below for search criteria gives the results you desire...

Code
Select All
vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBListed=>=" + vListStart, "!DBListed=<=" + vListEnd, "!DBCltNo=" + CltString) 

  
Back to top
 
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: XResultSetSearch ranges
Reply #4 - Jun 22nd, 2013 at 6:46pm
Print Post Print Post  
Hi Bharat,

Thanks for the suggestion, but it didn't work I'm afraid ... still getting a 0 result back ...
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XResultSetSearch ranges
Reply #5 - Jun 22nd, 2013 at 6:54pm
Print Post Print Post  
Set your search parameters into variable and WriteLn those variables before passing them to @XResultSetSearch. If they look correct, try them in a form by hand.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
BWETTLAUFER
Full Member
***
Offline



Posts: 216
Location: Cambridge, Ontario
Joined: Apr 9th, 2010
Re: XResultSetSearch ranges
Reply #6 - Jun 22nd, 2013 at 7:35pm
Print Post Print Post  
That's my issue ... it's my retrieve spec.  vListStart and vListEnd are the same values (so nothing to find, naturally)

So if vListStart is "2013-05-01", and I want to capture the whole month, how do I calculate vListEnd?

vListStart: 2013/05/01
vListEnd: 2013/05/01
  
Back to top
IP Logged
 
The Cow
YaBB Administrator
*****
Offline



Posts: 2530
Joined: Nov 22nd, 2002
Re: XResultSetSearch ranges
Reply #7 - Jun 22nd, 2013 at 11:54pm
Print Post Print Post  
BWETTLAUFER wrote on Jun 22nd, 2013 at 7:35pm:
That's my issue ... it's my retrieve spec.  vListStart and vListEnd are the same values (so nothing to find, naturally)

So if vListStart is "2013-05-01", and I want to capture the whole month, how do I calculate vListEnd?

vListStart: 2013/05/01
vListEnd: 2013/05/01


Don't. Instead increment the month (checking to make sure it isn't 12. If it is, reset to 1 and increment the year). Then retrieve, using >= for the start and just < for the end of the range. That will check if your date is greater than or equal to the start date and less than the end date, which is the first of the next month.
  

Mark Lasersohn&&Programmer&&Lantica Software, LLC
Back to top
IP Logged
 
Ray the Reaper
Global Moderator
Members
Lantica Support
*****
Offline


The One & The Only

Posts: 2480
Joined: Aug 20th, 2003
Re: XResultSetSearch ranges
Reply #8 - Jun 24th, 2013 at 6:54pm
Print Post Print Post  
Hello Blair,

This should also work for you. What it is doing is forcing a string search(]) on the first 7 characters of the date to see if they match the first 7 characters of the date in vListStart. So since a date appears as 2013/05/01 the first 7 characters would be 2013/05, so basically it's matching on the year and the month, ignoring the day of the month entirely.

Code
Select All
vRSHandle = @XResultSetSearch(@FN, "Debtors", SEARCH_MODE_AND, SEARCH_SYNTAX_QA, "!DBListed=]" + @Left(vListStart,7) + "..", "!DBCltNo="+CltString) 



-Ray
  

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