dbTalk Databases Forums  

search and indexs

comp.databases.xbase.fox comp.databases.xbase.fox


Discuss search and indexs in the comp.databases.xbase.fox forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
maani
 
Posts: n/a

Default search and indexs - 12-28-2004 , 01:34 AM






aoa
consider this scenario:

i have a table "abc" in my form's data environment. the table is given
the name "cursor1" by vfp.i set "order" property of this cursor to
"xyz" index. then i load the form.the effect is that records are
displayed in order of xyz.
i am also providing a search feature with a button named "find". when
the user clicks find,i run a query of the form:

select * from abc into cursor searchresult

now the problem is "how to set sort order of searchresult cursor same
as that of cursor1?".
i tried this code but it didnt work:

ord=ORDER()&&save current order i.e. cursor1's order
SELECT *;
FROM abc;
into cursor searchresults
SET ORDER TO (ord)&&set searchresults' order to same as that of
cursor1

but i recieve "table has no index order set".(which i think is perhaps
because searchresults does not have any index inherited of the table
abc.)
i hope somebody will reply.


Reply With Quote
  #2  
Old   
Stefan Wuebbe
 
Posts: n/a

Default Re: search and indexs - 12-28-2004 , 04:40 AM






Quote:
select * from abc into cursor searchresult

now the problem is "how to set sort order of searchresult cursor same
as that of cursor1?".
You can add an Order By clause to your Select-SQL statement
to get the desired order, e.g.
select * from abc Order By 4,2,3 into cursor searchresult

Quote:
but i recieve "table has no index order set".(which i think is perhaps
because searchresults does not have any index inherited of the table
abc.)
Yes, that's true. The SQL statement can take advantage of the
original table's index tags to optimize the query, especially when
there is a WHERE clause where the left side of the expression
exactly matches an existing index expression.
But the original index tags themselves won't be "inherited" by the
temporary result cursor.
See also SEEK() in help.


hth
-Stefan


"maani" <salman2k960 (AT) hotmail (DOT) com> schrieb
Quote:
aoa
consider this scenario:

i have a table "abc" in my form's data environment. the table is given
the name "cursor1" by vfp.i set "order" property of this cursor to
"xyz" index. then i load the form.the effect is that records are
displayed in order of xyz.
i am also providing a search feature with a button named "find". when
the user clicks find,i run a query of the form:

select * from abc into cursor searchresult

now the problem is "how to set sort order of searchresult cursor same
as that of cursor1?".
i tried this code but it didnt work:

ord=ORDER()&&save current order i.e. cursor1's order
SELECT *;
FROM abc;
into cursor searchresults
SET ORDER TO (ord)&&set searchresults' order to same as that of
cursor1

but i recieve "table has no index order set".(which i think is perhaps
because searchresults does not have any index inherited of the table
abc.)
i hope somebody will reply.


Reply With Quote
  #3  
Old   
maani
 
Posts: n/a

Default Re: search and indexs - 12-28-2004 , 10:52 PM



aoa
thnx stefan.actually, i wanted to write a generic code which i could
use in all of my forms. what i wanted was that the select statement get
ordered same as the orignal cursor.but nevermind if it didnt work.i
have used the sek() function.thanx again.


Reply With Quote
  #4  
Old   
Stefan Wuebbe
 
Posts: n/a

Default Re: search and indexs - 12-29-2004 , 02:36 AM




"maani" <salman2k960 (AT) hotmail (DOT) com> schrieb
Quote:
aoa
thnx stefan.actually, i wanted to write a generic code which i could
use in all of my forms. what i wanted was that the select statement get
ordered same as the orignal cursor.
You could use Order(), ATagInfo() etc. for table aliases and
CursorGetProp(..., 'SQL') to get the built-in Order By clauses of
views, if any.
So it would probably be quite complicated generic code, I think.


Quote:
but nevermind if it didnt work.i have used the sek() function.thanx again.
Great. You're welcome.


-Stefan


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.