Welcome! Log In Create A New Profile

Advanced

Search in a Memory-Table

Posted by Thomas 
Thomas
Search in a Memory-Table
August 14, 2008 07:31PM
Hi Windev Fans,

how can search in a Memory-Table with more search criteria? Tableseek() allows only one search criteria.

Best Regards


Thomas

Firetox
Re: Search in a Memory-Table
August 14, 2008 09:03PM
hello thomas

create a function yourself like

FUNCTION myTableSeek(p_myTable is string , p_mySearch is string)

// p_mySearch is a string which have the criteria like this
// myCol1=toto, myCol2=25,.............

v_indice is int
v_ind is int = 1

v_myCol is string
v_myVal is string

FindRow is boolean

IF p_myTable = "" THEN RESULT(-1)
FOR v_indice=1 _TO_  {p_myTable}..Occurrence
	FindRow = False
	v_ind=1
	LOOP
		v_myCol = ExtractString(ExtractString(p_mySearch,v_ind,","),1,"=")
		v_myVal = ExtractString(ExtractString(p_mySearch,v_ind,","),2,"=")
		
		IF v_myCol = "" THEN BREAK
		IF v_myCol =EOT THEN BREAK
					
		IF {p_myTable+"."+v_myCol}[v_indice] = v_myVal THEN 
			FindRow = True
		ELSE 
			IF FindRow THEN FindRow = False
		END
		v_ind++
	END
	IF FindRow THEN BREAK
END

IF v_indice > {p_myTable}..Occurrence THEN v_indice=-1
RESULT (v_indice)

example : my table named : tblTableSQL
and i have one colonne integer : IDCommande and one named : Nom

i use this function like this :
Trace(myTableSeek("tbl_TableSQL" , "IDCommande=2,nom=Sorofel-18"))

i have the indice of the first row find or -1

Regards
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: