Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem updating field - Cannot update cursor?
Message
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Problem updating field - Cannot update cursor?
Miscellaneous
Thread ID:
00294761
Message ID:
00294761
Views:
57
I'm having a problem getting a field update to work. Can anyone spot my error?

I have an Orders table and an OrderItems table. Orders has a 'Shipdate' field for a completed order, and OrderItems has a 'shipped' field for individual items that have been shipped. One routine is called when single-item orders are shipped and is intended to put the system date in both the Orders.shipdate and OrderItems.shipped fields. For some reason, it never fills the orderitems.shipped field.

Code follows below. c_Orders is a cursor containing the order_ids of all filled orders. I think I'm scanning the c_orders cursor, finding the matching item in the Orders table, updating it, then getting the matching order_id in the orderitems table and updating it. I thought that REPLACE FOR order_id = lcOrdNum would update at the same time all the records in orderitems that had that order_id. Am I wrong?


Suggestions gratefully accepted....
Neil Preston
SELECT Orders
	lcOrdersOldOrder = ORDER()
	SET ORDER TO order_id
	SELECT orderitems
	lcItemsOldOrder = ORDER()
	SET ORDER TO order_id
	SELECT c_Orders
	SCAN
		lcOrdNum = order_id
		SELECT Orders
		SEEK lcOrdNum
		IF FOUND()
			REPLACE shipdate WITH DATE()
		ELSE
			WAIT WINDOW AT 20,20 ' Order not found '
		ENDIF
		SELECT orderitems
		REPLACE shipped WITH DATE() FOR order_id = lcOrdNum

	ENDSCAN
Next
Reply
Map
View

Click here to load this message in the networking platform