Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Fool a cursor to fully buffered
Message
From
30/01/2004 11:35:49
Larry Long
ProgRes (Programming Resources)
Georgia, United States
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00871895
Message ID:
00872373
Views:
23
Perhaps I missed something. Why do you need to updated unmodified data?

>How can I fool a cursor into being fully buffered after setting table buffering? The situation we have is that we use cursorsetprop functions with the tableupdate and sqlcommit functions to update the live tables from a buffered cursor. The problem is that the updates to the local cursor are approaching a hundred thousand records and the updates to the local cursor get slower and slower as the buffer gets larger (5 hours). When I turn buffering off, the updates are quick (3 minutes), but then we can't use the following code technique. The batch update function works quickly, it is just populating the local buffered cursor that is killing us. I can turn buffering back on and then scan thru every record and replace each field with itself, but that does not buy us anything. Is there a quick way to fool fox into thinking every record in the local cursor needs to be updated?
>
>This is the routine I call with the buffered cursor that updates the back end. This is quick, just dealing with the buffered cursor is slow:
>
>
>	FUNCTION Cursor_Save_View(cCursor AS STRING, cTable AS STRING, cPKField AS STRING, tiDataSessionID AS INTEGER)
>		* This routine saves a whole cursor to the back end very quickly by tricking the cursor into behaving
>		* like a remote view.  This routine does not perform pre-maintenance on the table: like converting
>		* blank dates into valid SQL Server values or initializing null values.
>		* Primary key values must be assigned before calling this routine.
>		LOCAL loRec, llRetVlu
>		cPKField=IIF(EMPTY(cPKField),'PK',cPKField)
>		tiDataSessionID = IIF(EMPTY(tiDataSessionID),this.DataSessionId,tiDataSessionID)
>		SET DATASESSION TO tiDataSessionID
>		TRY
>			SELECT (cCursor)
>			SCATTER MEMO NAME loRec
>			* Make the cursor updatable to the back end and wrap in a remote transaction
>			=SQLSetProp(THIS.iCH, "Transactions", 2)
>			=CURSORSETPROP("Tables", cTable)
>			=CURSORSETPROP("FetchMemo",.T.)
>			=CURSORSETPROP("KeyFieldList", cPKField)
>			=CURSORSETPROP("UpdatableFieldList", THIS.AllMembers(loRec))
>			=CURSORSETPROP("SendUpdates", .T.)
>			=CURSORSETPROP("UpdateNameList", THIS.AllMembers(loRec,cTable))
>			* Update Locally
>			IF TABLEUPDATE(1,.T.,cCursor)
>				* Commit the changes
>				=SQLCOMMIT(THIS.iCH)
>				llRetVlu = .T.
>			ELSE
>				* Something went wrong, log it and roll back the transaction
>				THIS.ERROR(0,'TableUpdate',0)
>				=SQLROLLBACK(THIS.iCH)
>			ENDIF
>			=SQLSetProp(THIS.iCH, "Transactions", 1)
>		CATCH TO oErr
>			llRetVlu = .F.
>			THIS.LOG("ERROR - "+oErr.MESSAGE)
>		FINALLY
>			IF SQLGETPROP(THIS.iCH,"Transactions")=2
>				* If the Tansaction was not closed, then something went wrong with the update
>				llRetVlu = .F.
>				THIS.LOG("ERROR - Transaction left in flux, therefore performed a rollback")
>				=SQLROLLBACK(THIS.iCH)
>				=SQLSetProp(THIS.iCH, "Transactions", 1)
>			ENDIF
>			* Disconnect the cursor and cleanup
>			=CURSORSETPROP('SendUpdate', .F.)
>			=CURSORSETPROP("Tables")
>			=CURSORSETPROP("KeyFieldList")
>			=CURSORSETPROP("UpdatableFieldList")
>			=CURSORSETPROP("UpdateNameList")
>		ENDTRY
>		SET DATASESSION TO THIS.DATASESSIONID
>		RETURN llRetVlu
>	ENDFUNC
>
L.A.Long
ProgRes
lalong1@charter.net
Previous
Reply
Map
View

Click here to load this message in the networking platform