Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Buffering cursors
Message
De
10/12/2013 12:00:21
 
 
À
10/12/2013 11:23:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Programmation Orientée Object
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Divers
Thread ID:
01589683
Message ID:
01589696
Vues:
54
>>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.
"You don't manage people. You manage things - people you lead" Adm. Grace Hopper
Pflugerville, between a Rock and a Weird Place
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform