Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Problem with tableupdate & remote views
Message
General information
Forum:
Visual FoxPro
Category:
Client/server
Title:
Problem with tableupdate & remote views
Miscellaneous
Thread ID:
00611955
Message ID:
00611955
Views:
44
Sergey,

You've been good for a fix or two in the past, and I'm getting pretty desperate here, so please forgive the intrusion. I've posted this before, but the ideas I got did not fix the problem.

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 records with 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 in a browse.

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.

The pattern that seems to emerge is, that the records that are inserted and then updated with REPLACE... come through ok. The ones that are already in the view (and base table) do not get updated properly.

Is this known behaviour or am I doing something wrong?


TIA
Peter Pirker


Whosoever shall not fall by the sword or by famine, shall fall by pestilence, so why bother shaving?

(Woody Allen)
Next
Reply
Map
View

Click here to load this message in the networking platform