Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
More XML Questions
Message
De
05/02/2005 00:48:58
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00983749
Message ID:
00984120
Vues:
22
Kevin,

>2) If I have a stored proc that performs a SQL query and returns
>the results as XML, can I later reconvert only the changed records
>to XML and pass them back to be saved, or do I need all records?

I don't have much time right now to get into details and explore this with you, but XMLAdapter can both generate and consume XML in diffgram format, allowing just information about changed/added/deleted records to be sent back instead of the entire file.

>3) Can someone provide an example of how to update the base table
>from a modifed set of data represented as an XML string?

I have not tested all of this thorougly, so you might have to experiment a bit, but assuming that you use XMLAdapter to read in the XML sent back from your query and convert it into a cursor...

After your changes are made to the cursor,
1) Set XMLAdapter.IsDiffGram = .T.
2) Call XMLAdapter.ToXML and use the params to indicate your preference of "include before section" and "send changes only" -- read the Help entry for ToXML method for details and note the dependence of the params on the value of XMLAdapter.IsDiffGram (some combinations of settings won't work).
3) Send the XML containing the diffgram to your other object
4) Inside Data object, use XMLAdapter.LoadXML to read in the incoming XML and apply it to the table by calling the XMLTable.ApplyDiffgram method -- specifying the alias of the table to update (can be a path and filename of a DBF that is not even open) and optionally passing a CursorAdapter object as the second param (which can use the CA to update a remote data source like SQL Server if you need that). If you don't pass a CursorAdapter reference to the ApplyDiffgram method, XMLTable will do the update to the Fox table itself.

NOTE: For this to work, you may need to specify the KeyField property as .T. for the XMLField object(s) in the XMLTable Fields collection that represent the key field that can identify the correct record for updating. This would be done before you call XMLTable.ApplyDiffgram. In a quick test, it appeared that the KeyField property must be set, but I can't say for sure without more testing.

NOTE: Please read the help on these methods and properties, and notice that the ApplyDiffgram method is in the XMLTable class and not in the XMLAdapter class (your XMLAdapter instance will have an XMLTable object in its Tables collection after XMLAdapter.LoadXML reads the incoming.) Usually, after XMLAdapter.LoadXML, you call the XMLTable.ToCursor method for each table in the collection, but for diffgram, you would call XMLTable.ApplyDiffgram.

That's the theory, at least. There might be another step I've missed, and it will be several days before I will have time to explore this further and assist you with it, but the mechanisms appear to be there to create a diffgram from changed data and then apply that diffgram to Fox tables. Thanks for getting my curiosity up related to this -- now I've got to find time to check it out in more detail and post some code, in case anyone is interested. Or, maybe someone else who has done this will chime in...
David Stevenson, MCSD, 2-time VFP MVP / St. Petersburg, FL USA / david@topstrategies.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform