Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
To Vlad, please give me an example
Message
From
05/09/2001 07:22:37
 
 
To
05/09/2001 06:59:45
Henry Sudarma
Jakarta Institute of Technology
Jakarta, Indonesia
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00552403
Message ID:
00552408
Views:
15
Hi!

Assume table2 is related (child) table with buffering mode. Here is a very simple and brief code sample without much of errors checking on how to handle collisions (case when anotehr user already changed record that you going to update).
begin transaction
Replace table2.value with table2.value+numAmount
if !tableupdate(.T.,.F.)
  && assure we have all values in fields that are latest
  for i=1 to fcount()
    if !type(field(i))=='G' && general type fields are not comparable
      if !(OldVal(field(i))==CurVal(field(i))) or 
          IsNull(OldVal(field(i)) and !IsNull(CurVal(field(i)) or
          !IsNull(OldVal(field(i)) and IsNull(CurVal(field(i))
        if getfldstate(field(i)) > 1 && field is changed
          && here we see this field is changed on server and we're trying to write it over
          && here you can improve to do not overwrite latest changes or overwrite them
          && or just show message box to user about change
          
          && in case to leave value from another user on the server:
          replace (field(i)) with CurVal(field(i)) 
          && in case to overwrite value by you - do nothing.
        endif
      endif
    endif
  endfor
  && again, do updating of the Value field by using as latest amount as possible
  Replace table2.value with CurVal(table2.value)+numAmount
  = tableupdate(.T.,.T.)
endif
end transaction
HTH.

>Can you give me example how i can update my example with tablebuffer?
>For example i have a one many relation table, in many relation i need to decrease the value at another table. I need check the valid last value, and i also need to decrease the value from the valid value
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Reply
Map
View

Click here to load this message in the networking platform