Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Trying to use updateable views...
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00155397
Message ID:
00155429
Vues:
21
>>I've written a little test routine to familiarize myself with updateable views... It does not seem to be working as expected.
>>
>>When I browse the view and change something... that change should be saved to the dbf table using TABLEUPDATE() right? Well, the changes are not being saved...
>>
>>I'm sure it's something simple but I'm just not catching it.
>>
>>Here's the code:
>>* I want to use pessimistic row buffering
>>IF CURSORSETPROP("Buffering", 2, "TstParent" ) AND CURSORSETPROP("Buffering", 2, "TstChild" )
>
>Larry, first you don't need to open your tables or set any kind of buffering for them if you intend to use views.
>
>
>> cPrntID = '001'
>>
>> CREATE DATABASE TestView
>>
>> CREATE SQL VIEW TestView AS SELECT .F. AS MARKED, TstParent.*, TstChild.ChildName ;
>> FROM TstParent LEFT JOIN TstChild ON TstParent.PrntID=TstChild.PrntID ;
>> WHERE TstParent.PrntID=?cPrntID
>
>You created the view programmatically here, but you didn't set up any view properties (by default "SendUpdates" property for your view is .F.) or view field properties. You have neither "KeyField" property set for the primary key field in your view, nor "Updatable" property for the fields you want to update.
>
>If you still want to create your view programmatically, you have to set properties through DbSetProp() like:
>
>DBSetProp('TESTVIEW.prntid', 'Field', 'KeyField', .T.)
>DBSetProp('TESTVIEW.prntname', 'Field', 'Updatable', .T.)
>DBSetProp('TESTVIEW', 'View', 'SendUpdates', .T.)
>
>You can to modify your test database and modify the view in the View designer to see how does it look there. Also run the GenDBC utilitu from VFP and see the resulting code, which contains all necessary commands to re-create it programmatically.
>
>Another thing, that with JOIN you have there you will get 6 records with the same key from parent table and if you set tstParent.prntid as keyfield you will get nothing good but "Update Conflict" :) It will work only if you set tstChild.prntid as a keyfield.
>I don't know why you were trying to set pessimistic buffering for your tables, but keep in mind that views are optimistic by their nature. You cannot set pessimistic buffering for the view.
>
>HTH,
>Nick

Thanks Nick,

I'm looking at GenDBC right now...

I can see I have a lot to learn but it seems that this is the ideal way to go for someone who is proficient at it...

Thanks again
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform