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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using an Updatable Cursor in VFP 6

Status
Not open for further replies.

VFP6

Programmer
Jan 2, 2001
6
US
Hello,

I have created a CURSOR that has application wide scope. Here is a sample of how I have written this code:
* Cursor Creation
PUBLIC myCur
CREATE CURSOR myCur (cemp C(9) UNIQUE, clname C(25) UNIQUE, cfname C(25) UNIQUE)

Later in the application I have some code that generates a query to load this CURSOR. Example of this code:
* Cursor Load
SELECT cemp, clname, cfname FROM employee WHERE (This will vary based on user entry)

When the form that uses this CURSOR is accessed I need set the ORDER using this code:
SET ORDER TO TAG clname ASC

PROBLEM:
When I attempt the SET ORDER command I get an myCur INDEX ERROR. What am I doing wrong? I thought that the UNIQUE keyword creates a candidate index for the field and assigns the index tag the same name as the field.

Thank you,
Anthony
 
VFP6

How about

SELECT cemp, clname, cfname FROM employee ORDER BY clname WHERE ....


or

SELECT cemp, clname, cfname FROM employee WHERE (This will vary based on user entry)
Index on clname tag clname

Note : only one index permitted for a temporary cursor. But multiple orders

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hello Anthony.

>> When I attempt the SET ORDER command I get an myCur INDEX ERROR. What am I doing wrong? I thought that the UNIQUE keyword creates a candidate index for the field and assigns the index tag the same name as the field. <<

You are wrong. The UNIQUE keyword creates a unique index. All this does is specify that any record with a duplicate index key value not be included in the index file. Only the first record with the original index key value is included in the index file.






Marcia G. Akins
 
Thanks Mike,

I have been looking through MSDN while waiting for a response and I am now using the "INDEX ON clname TAG clname" method. Since I attempted to do this on more than one field I discovered that I am only permitted to use a sngle INDEX on the temporary CURSOR.

The current application, which has been in place for around ten years, uses SEEK and SET ORDER TO commands on multiple fields for each data form. Can this be achieved for this CURSOR if it is an updatable CURSOR? That leads me to my next question. Am I creating an updatable cursor correctly? Is there something that I am missing?

Thanks,
Anthony
 

An updatable cursor as in "being able to input new records"?

The VFP7.0 and VFP8.0 have a readwrite clause that allows what you trying to acheive, but for VFP6.0 you may consider the suggestion in faq184-2800.

Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Hi Mike,

Thanks again. I will test this out with my app in a minute.

Anthony
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top