Safe Select Doubt  
Author Message
General Fault





PostPosted: Visual FoxPro General, Safe Select Doubt Top

Hello

I was trying to use Safe Select, and it doesn' t work, look at the following:

* This is the working cursor

SELECT code FROM product WHERE 0 = 1 INTO CURSOR tmpProduct

* This is the real query

SELECT * FROM product WHERE code=7 INTO CURSOR curdummy

* Clear the working cursor and append the results of curdummy

SELECT tmpProduct

ZAP IN tmpProduct

APPEND FROM DBF("curdummy")

USE IN curdummy

Anyone should expect a tmpProduct table filled only with products with a code of 7, but in fact the result is a tmpProduct table filled with all the records in the PRODUCT table.

I inserted a BROWSE after I populated the curdummy cursor to see what was happening and it showed the desired results, only products with a code of 7, but after I append the results of curdummy into tmpProduct I browse it and it shows all the records of the PRODUCT table.

What could be wrong THANKS



Visual FoxPro1  
 
 
AndyKr





PostPosted: Visual FoxPro General, Safe Select Doubt Top

Look up the NOFILTER clause in the help file!

VFP will, if a query is fully optimizable, return a filtered view by default rather than create a physical cursor. The NOFILTER clause tells VFP to create the cursor and then all will be well. Try it like this:

SELECT * FROM product WHERE code=7 INTO CURSOR curdummy NOFILTER



 
 
Don Higgins





PostPosted: Visual FoxPro General, Safe Select Doubt Top

And most importantly what is the recordsource for the grid It should be tmpProduct



 
 
General Fault





PostPosted: Visual FoxPro General, Safe Select Doubt Top

Yes, is tmpProduct.

Thanks.


 
 
Don Higgins





PostPosted: Visual FoxPro General, Safe Select Doubt Top

Then after using Andy's response make sure that this cursor is the database in scope when the grid is fired.

I do a SET STEP ON on my procedures for grids until I know it is correct. Put DBF(), and RECCOUNT() in the watch window and make sure the they don't change. I had a class once that did this behind the scenes and it took me awhile to figure it out.

Don