Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Cursor manipulation questions;
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Cursor manipulation questions;
Miscellaneous
Thread ID:
00256590
Message ID:
00256590
Views:
46
I'm running into problems getting a cursor to behave like I want it to.

Background: Using VFP6 SP3 with a database consisting of free tables (We also use FPW26 for some tasks.) The main data table contains info on students. Another table is used for orders, and may contain more up-to-date address info on the students.

I'm working on a routine to compare the two tables, and if the Students table home address is blank, or is different from that in the orders address, the orders address is inserted into the field in the students table. I also want to create a table containing info on the changes so they can be examined and/or reported if necessary.
If the orders record address is blank, I want to skip the update and remove it from the results table.

Approach: (Excerpt only - not entire listing)

1 USE students IN 0 ORDER student_id
2 USE orders IN 0 ORDER student_id

3 DO NoHomeAddress
4 DO cursorprep
5 DO merge

..... code continues....

6 PROCEDURE NoHomeAddress
* locate empty address fields in students table where data exists in orders table.

7 SELECT students.student_id, students.fname, students.lname,;
students.YEAR, students.hm_address, students.hm_city, students.hm_state,;
students.hm_zip, students.hm_zip5_4, students.hm_phone,;
orders.hm_address, orders.hm_city, orders.hm_state, orders.hm_zip,;
orders.hm_zip5_4, orders.hm_phone;
FROM students INNER JOIN orders ;
ON students.student_id = orders.student_id;
WHERE orders.hm_address > ' ';
AND students.hm_address = ' ';
ORDER BY students.student_id;
INTO CURSOR Temp nofilter
8 USE temp AGAIN IN 0 ALIAS c_Addresses
8A *USE (dbf()) AGAIN IN 0 ALIAS c_Addresses
9 USE
10 RETURN

11 PROCEDURE cursorprep
12 SELECT c_Addresses
13 *INDEX ON student_id TAG student_id
14 SET RELATION TO student_id INTO orders ADDITIVE
15 SET RELATION TO student_id INTO students ADDITIVE
16 RETURN




Problem:
Lines 8 or 8A - I'm trying to convert the read-only cursor from the SELECT statement to an updatable cursor so I can eliminate records with bad address info. When using line 8, sometimes I will get 'File not found' errors. If I use lin 8A, it returns 'Invalid path or filename'. In addition, the cursor c_Addresses does not contain all the fields from the cursor Temp. What is really strange is that at one time or another, both of these forms have worked in the past on this routine.

Lines 12 - 14: Line 13 was added because of errors stating that no index order was set. It worked for awhile. Now it gives me a dialog asking if I want to overwrite student_id, then halts on line 14, stating that the table must be opened exclusively. Commenting line 13 appears to let it work, but why?

The behavior almost appears as if there exists a table called c_Addresses containing earlier data, but I can't find one anywhere.

I would greatly appreciate any wisdom you may offer.

Thank you very much,

Neil Preston
Next
Reply
Map
View

Click here to load this message in the networking platform