Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Strange TABLEUPDATE behaviour?
Message
 
To
25/01/2002 10:26:45
General information
Forum:
Visual FoxPro
Category:
Client/server
Miscellaneous
Thread ID:
00610484
Message ID:
00610522
Views:
19
I have seen weird behaviors with TableUpdate myself. Some of the things that have caused me trouble are:

* Using TableUpdate() with numeric parameters. Althought this is what the help recommends, I've found that using the numeric valid does not always work. I try to use instead TableUpdate( .T. )

* If you use TableUpdate() with numeric parameters. You may need to loop several times until getnextmod() returns 0 to make sure all your changes were commited. I know this does not make sense since TableUpdate() should be able to process all records at once, but I have found that sometimes TableUpdate() does not work as expected.

* Check the value in BatchUpdate. The default is 1 and everything works fine with that value. I've found that changing that value causes sporadic (random?) problems with TableUpdate().

I hope this helps.

>This is simplified pseudo code of the program that's giving me problems.
>
>
>SELECT InputFiles      && Contains a list of files to process
>   SCAN
>       =SQLEXEC([SELECT * FROM MyRemoteView],MyView) && SQL Server 2K
>       * MyRemoteView Contains MAX(Timestamp) down to milliseconds
>       * for all unique records´from it's base table
>       * Boy I hope I've explained this properly
>       * Anyway, that's why I keep calling the SQLEXEC for every TABLEUPDATE()
>       INDEX ON ...TAG MyTag...
>       CREATE Cursor MyCursor ...
>       lcFilename=InputFiles.FileName
>       APPEND FROM lcFileName
>       SCAN
>           SCATTER MEMVAR
>           IF SEEK(MyExpression,MyView,...);
>              AND MyCursor.Timestamp>MyView.Timestamp
>              * Compare timestamps to make sure the same stuff does
>              * not get added twice
>              REPLACE MyView.Timestamp WITH MyCursor.Timestamp
>              REPLACE some values in MyView with some other values
>           ELSE
>              INSERT INTO MyView FROM MEMVAR
>           ENDIF
>           * Increment the number of observations with 1
>           REPLACE MyView.NumerOfObs WITH MyView.NumerOfObs+1
>       ENDSCAN
>
>       * We have now processed 1 inputfile, update MyView
>       	llResult=TABLEUPDATE(2,.T.,"MyView",Errors)
>
>       * Check if the update returns .T. and handle any records
>       * that did not make it through...
>
>        SELECT InputFiles
>ENDSCAN
>
>
>Now what happens, in all cases so far, TABLEUPDATE returns .T.
>The debugger tells me that my MyView has incremented the NumberofObs to the expected value and everything looks fine.
>
>When I use the SQL Server Query analyzer and open the SQL Server view, it quickly becomes clear that not everything was updated.
>
>The very first file on an empty MyView and base table makes it through ok.
>
>After that, most records are ok and have indeed been inserted and/or updated, but some are not.
>
>I have not been able to find any pattern in the ones that are not, it all seems pretty random.
>
>Any ideas?
>
>TIA
>BTW, I do set the KeyFields, Tables and all the other properties, so that's not it.
Hector Correa
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform