Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SET DELETE ON QUESTION RELATING TO SQL

Status
Not open for further replies.

hawkieboy

Programmer
Apr 30, 2002
49
GB
Hi All

I have a strange one:

I run the following with set deleted on

SELECT * FROM GHDD3 INTO CURSOR RESULTS WHERE alltrim(UPPER
(ghdsname)) = "SHIT"
WAIT WINDOW STR(RECCOUNT('RESULTS'))

the wait wind shows 0

when i run the above with set deleted off the wait wind shows the record count of the ghdd3 table.

the table ghdd3 has no deleted records so I am a bit confused. could anyone explain what is going on to me

Many Thanks

Nick

your help and advice is appreciated
 
Nick,
Any time you Select all and only the fields from a single table, VFP will try to save time by creating a "filtered" result set on the original table, rather than creating a "real" cursor. Therefore RESULTS will actually point to the original table! If you change the SELECT to
Code:
SELECT *, " " as junk FROM GHDD3 INTO CURSOR RESULTS ;
  WHERE alltrim(UPPER(ghdsname)) = "SHIT"
then VFP is forced to create a real cursor, and I believe you'll find that you'll get what you expect.

Rick
 
If you add the keyword NOFILTER to the end of the SQL statement, you also will get a real cursor.

Stewart
 
Thanks Stewart, I always forget the "new" fixes (Since VFP 6.0 SP3?) - I've been using the old techniques for too long!

Rick
 
You can also use _TALLY to get at the number of records returned by the last operation, which in this case would be the record count, even without resorting to the use of NOFILTER etc.. If you don't actually need the results in a distinct table of their own (i.e. a filtered view of an existing table will suffice), not resorting to NOFILTER can sometimes make a significant difference to performance.

Keith
 
Thanks guys your comments have been really helpfull



your help and advice is appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top