Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Buffering cursors
Message
From
10/12/2013 12:11:45
 
 
To
10/12/2013 12:00:21
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01589683
Message ID:
01589699
Views:
43
>>>Why would one do this?
>>>
>>>Scenario:
>>>
>>>Data is pulled from SQL server into cursor for an individual
>>>Cursor is then buffered
>>>Cursor is updated from input form (there is no update/commit on the cursor, just replaces)
>>>SQL server is updated from cursor.
>>>Data is repulled from SQL server into cursor for the same individual
>>>
>>>We have instances where (at least) one field is not making it 'back' from SQL server and is causing issues further downstream in the process and, of course, it's only happening on occasion.
>>
>>
>>Dorris,
>>
>>A possible scenario
>>
>>Entering a value into a textbox bound to a field of the cursor
>>The textbox does not lose the focus ( ie, the controlsource is not updated yet) eg by clicking on a toobarbutton
>>Update Sqlserver with cursor
>>
>>
>>Update : and how do you update sql server with the data in the cursor ?
>
>the input form is HTML, so there's no 'direct' entry.
>There are two update methods being used, one does an update from memvar which only updates the cursor
>
>LPARAMETERS tcAlias
>
>IF EMPTY( tcAlias )
>  tcAlias = this.cfetchalias
>ENDIF
>
>LOCAL lnNumFields, lnX, lnSelect, lcField, lcMemVar
>LOCAL ARRAY laFields[1]
>
>lnSelect = SELECT()
>SELECT (tcAlias)
>
>lnNumFields = AFIELDS( laFields )
>FOR lnX = 1 TO lnNumFields
>
>  lcField  = laFields[lnX, 1]
>  lcMemVar = "m." + lcField
>* leave the pk alone
>  IF ALLTRIM(UPPER(lcField)) == ALLTRIM(UPPER(this.cpkfield))
>	LOOP
>  ENDIF
>
>  IF NOT &lcField == &lcMemVar
>	REPLACE &lcField WITH &lcMemVar
>  ENDIF
>ENDFOR
>
>SELECT (lnSelect)
>
>
>
>The SQL update is called from this chunk of code
>
>If CursorGetProp("Buffering")=5
>  lnRecno = Recno()
>  lnGetNextModified = Getnextmodified( 0 )
>  Do While lnGetNextModified # 0
>    Go lnGetNextModified
>    lcUpdateStatus = Getfldstate(-1)
>    If Left( lcUpdateStatus, 1) = "2"
>      * note the update stored procedure needs to be setup to accept "@delete_tablename = 1" parameter
>      lcUpdateMessage = "exec " + lcDatabase + "." + This.db_schema + "." + lcPrefix + "_update_" + This.cTableName + " @" + This.cpkfield + ;
>        "=" + Alltrim(Str(Evaluate(This.cpkfield))) + ", @update_user = '"+ lcUpdateUser + "', @update_program = '" + lcUpdateProgram + "', " ;
>        + " @delete_" + This.cTableName + " = 1" + ;
>        IIF(  Type( This.laUpdateTables[lnY] + ".ssnum") # "U", ", @demoid=" +   Alltrim(Str(Int(Val(Eval( This.laUpdateTables[lnY] + ".ssnum"))))), "") + ;
>        IIF( This.AlwaysSendAcctid And Not Empty( tcAcctId ), ", @acctid='" + tcAcctId + "'", "")
>
>      llOk = This.SQLExec( lcUpdateMessage )
>      If Not llOk
>        llUpdatesOk = .F.
>      Endif
>
>      lcUpdateMessage = ""
>
>*And so forth
>
>
>There's about another page and a half of code like this.


If the html values get to the m.lcField variable OK, I don't know
Gregory
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform