Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Buffering and Tableupdate()
Message
 
To
13/04/2006 12:18:13
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01113462
Message ID:
01113496
Views:
19
>>>If the controls on a form display and operate on data contained in a temporary cursor, how do you save the revised data back into the original table? I'm experimenting with the following code sequence to try and figure this out but I can't seem to get it right.
>>>
>>>
>>>select * from test_financing into cursor crstemp readwrite
>>>set multilocks on
>>>=cursorsetprop("buffering",5,"test_financing")
>>>select crstemp
>>>go top
>>>replace amount with 2000
>>>=tableupdate()
>>>
>>>
>>>Any help will be appreciated.
>>
>>Use CursorAdapter or Updatable Local View for this.
>>I suupose this is only an example of what you want to do, but if you do this in a regular bases you must consider using LV or CA. That will make you life easier :o)
>----------------------------------------------------------------------
>
>Thanks guys. This situation has additional complexities that will have to be dealt with. Such as . . . the views will need to be constructed dynamically. Is that possible? I constructed a test view to experiment with, the code is:
>
>
>SELECT Test_financing.tip_id, Test_financing.amount,;
>  Test_financing.source, Test_financing.year, Test_financing.phase;
> FROM ;
>     Z:\DFREEMAN\TIP\DATA\TEST_FINANCING.DBF;
> WHERE  Test_financing.year = ( 2007 );
> ORDER BY Test_financing.tip_id
>
>DBSetProp(ThisView,"View","SendUpdates",.F.)
>DBSetProp(ThisView,"View","BatchUpdateCount",1)
>DBSetProp(ThisView,"View","CompareMemo",.T.)
>DBSetProp(ThisView,"View","FetchAsNeeded",.F.)
>DBSetProp(ThisView,"View","FetchMemo",.T.)
>DBSetProp(ThisView,"View","FetchSize",100)
>DBSetProp(ThisView,"View","MaxRecords",-1)
>DBSetProp(ThisView,"View","Prepared",.F.)
>DBSetProp(ThisView,"View","UpdateType",1)
>DBSetProp(ThisView,"View","UseMemoSize",255)
>DBSetProp(ThisView,"View","Tables","test_financing")
>DBSetProp(ThisView,"View","WhereType",3)
>
>DBSetProp(ThisView+".tip_id","Field","DataType","N(6,2)")
>DBSetProp(ThisView+".tip_id","Field","UpdateName","test_financing.tip_id")
>DBSetProp(ThisView+".tip_id","Field","KeyField",.F.)
>DBSetProp(ThisView+".tip_id","Field","Updatable",.T.)
>
>DBSetProp(ThisView+".amount","Field","DataType","N(6)")
>DBSetProp(ThisView+".amount","Field","UpdateName","test_financing.amount")
>DBSetProp(ThisView+".amount","Field","KeyField",.F.)
>DBSetProp(ThisView+".amount","Field","Updatable",.T.)
>
>DBSetProp(ThisView+".source","Field","DataType","C(5)")
>DBSetProp(ThisView+".source","Field","UpdateName","test_financing.source")
>DBSetProp(ThisView+".source","Field","KeyField",.F.)
>DBSetProp(ThisView+".source","Field","Updatable",.T.)
>
>DBSetProp(ThisView+".year","Field","DataType","N(4)")
>DBSetProp(ThisView+".year","Field","UpdateName","test_financing.year")
>DBSetProp(ThisView+".year","Field","KeyField",.F.)
>DBSetProp(ThisView+".year","Field","Updatable",.T.)
>
>DBSetProp(ThisView+".phase","Field","DataType","C(5)")
>DBSetProp(ThisView+".phase","Field","UpdateName","test_financing.phase")
>DBSetProp(ThisView+".phase","Field","KeyField",.F.)
>DBSetProp(ThisView+".phase","Field","Updatable",.T.)
>
>
>
>but it errors if I try to run it as a program. Also, if I :
>
>
>use testview
>repl amount with somenumber
>=tableupdate()
>
>the new data is not saved back into the original file. So I must still be missing something.


As I said you can use CA, Nost so many lines :o)
The same View definition, rewroted to CA will looks like this:
oCA = CREATEOBJECT([CursorAdapter])
TEXT TO oCa.SelectCmd PRETEXT 15 NOSHOW 
     SELECT Test_financing.tip_id, Test_financing.amount,
            Test_financing.source, Test_financing.year, Test_financing.phase
            FROM Z:\DFREEMAN\TIP\DATA\TEST_FINANCING.DBF
            WHERE  Test_financing.year = ( ?m.lnYear )
    ORDER BY Test_financing.tip_id
ENDTEXT
oCa.BufferModeOverride = 5
oCa.DataSourceType = [NATIVE]
oCa.SendUpdates    = .t.
oCa.WhereType      = 1
oCa.Tables         = [Test_financing]
oCa.FetchSize      = -1
oCa.KeyFields      = [Tip_ID]
oCa.UpdateNameList = "Amount Test_financing.Amount, Source Test_financing.Source,"+;
                     "year   Test_financing.year  , phase  Test_financing.phase"
oCa.UpdatableFieldList = "Amount, Source, year, phase"
oCa.Alias              = [crsTest]

m.lnYear = 2007
oCa.CursorFill()
REPLACE Ammount WITH 100
TableUpdate(1, .t., [crsTest])
Of course in this example there is no error handling :o)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform