Welcome! Log In Create A New Profile

Advanced

About search on string in table

Posted by PETER ZHOU 
PETER ZHOU
About search on string in table
July 30, 2008 04:14PM
n = TableSeek(Table_Candidate.CandidateName,EDT_SearchFullName,False)
will search for string starting with (generic) in <sought element>

n = TableSeek(Table_Candidate.CandidateName,EDT_SearchFullName,True)
will do exact match search in <sought element>

How about i want to do a search on string within the <sought element> ?

Regards,

PETER ZHOU
PETER ZHOU
Re: About search on string in table
July 30, 2008 04:30PM
Quote
PETER ZHOU
n = TableSeek(Table_Candidate.CandidateName,EDT_SearchFullName,False)
will search for string starting with (generic) in "sought element"

n = TableSeek(Table_Candidate.CandidateName,EDT_SearchFullName,True)
will do exact match search in "sought element"

How about i want to do a search on string within the "sought element" ?

Regards,

PETER ZHOU

Sorry...forgot abt the word "sought element"
PETER ZHOU
Re: About search on string in table
July 31, 2008 09:32AM
Quote
PETER ZHOU
Quote
PETER ZHOU
n = TableSeek(Table_Candidate.CandidateName,EDT_SearchFullName,False)
will search for string starting with (generic) in "sought element"

n = TableSeek(Table_Candidate.CandidateName,EDT_SearchFullName,True)
will do exact match search in "sought element"

How about i want to do a search on string within the "sought element" ?

Regards,

PETER ZHOU

Sorry...forgot abt the word "sought element"

Hi,

Any suggestion ?
LS
Re: About search on string in table
July 31, 2008 10:47AM
PROCEDURE SearchInColumn(sTableName is string,sColumnName is string,sFindString is string,iRowStart=1)
sSearch is string = sTableName+"."+sColumnName
iCnt,iTblCnt is int
iTblCnt = TableCount(sTableName)
//Check if iRowStart not is lower or equal than 0 and not greater than the table rowcount.
//Because it will throw an exception.
IF Val(iRowStart) <= 0 THEN iRowStart = 1
IF Val(iRowStart) > iTblCnt THEN RESULT -1
//Perform search
FOR iCnt = iRowStart TO iTblCnt
   IF Position({sSearch,indControl}[iCnt],sFindString) > 0 THEN RESULT iCnt //return rownumber
END
//found nothing
RESULT -1

Something like this. I haven't tested this, but it should work.
Paulo Oliveira
Re: About search on string in table
July 31, 2008 10:47AM
i don't know any single instructions for this.
the only way i can think of is using FOR loop.

If you are using a browsing table you must be careful (speed problem) if your db table is big, the problem is the same with tableseek or FOR.
PETER ZHOU
Re: About search on string in table
August 01, 2008 02:01PM
Quote
LS
PROCEDURE SearchInColumn(sTableName is string,sColumnName is string,sFindString is string,iRowStart=1)
sSearch is string = sTableName+"."+sColumnName
iCnt,iTblCnt is int
iTblCnt = TableCount(sTableName)
//Check if iRowStart not is lower or equal than 0 and not greater than the table rowcount.
//Because it will throw an exception.
IF Val(iRowStart) <= 0 THEN iRowStart = 1
IF Val(iRowStart) > iTblCnt THEN RESULT -1
//Perform search
FOR iCnt = iRowStart TO iTblCnt
   IF Position({sSearch,indControl}[iCnt],sFindString) > 0 THEN RESULT iCnt //return rownumber
END
//found nothing
RESULT -1


Thanks!

I think it's works great...but don't know how's the speed issue when the data increases
Something like this. I haven't tested this, but it should work.
King
Re: About search on string in table
August 03, 2008 10:49AM
Hi

Tableseek doesn't come with inStr wildcard search capabilities.

Best to do is having that column indexed in hyperfile or other database and applying sqlStmts 'like' or '%' instead.

Perhaps pcsoft may consider this as an issue and will add it on Tableseek function
for next version.

Regs

King
Ben
Re: About search on string in table
August 03, 2008 03:13PM
From experience its better to handle all searches on the database side before populating the grid. The database engine is better equiped with years of algorythm evolvement to handle seaches in a much more efficient way.

Leo Voet
Re: About search on string in table
August 10, 2008 10:50PM
Quote
Ben
From experience its better to handle all searches on the database side before populating the grid. The database engine is better equiped with years of algorythm evolvement to handle seaches in a much more efficient way.

yep.... unless you are using Hyperfile...winking smiley
Author:

Your Email:


Subject:


Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically. If the code is hard to read, then just try to guess it right. If you enter the wrong code, a new image is created and you get another chance to enter it right.
Message: