Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Begin Transation e TableUpdate
Message
From
26/11/2002 16:12:08
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivia
 
 
To
26/11/2002 10:44:52
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00726899
Message ID:
00727299
Views:
14
This message has been marked as the solution to the initial question of the thread.
>Gracias Hilmar
>
>Mas tenho mais uma dúvida
>
>Por favor analisem este código e comentem o que está bem e o que está mal .
>Muito obrigado

>
>
>BEGIN TRANSACTION
>
>Select tabela1
>=TableUpdate(1,.T.)
>FLUSH
>
>Select tabela2
>=TableUpdate(1,.T.)
>FLUSH
>
>Select tabela3
>=TableUpdate(1,.T.)
>FLUSH
>
>IF TableUpdate(.T., .F., "Tabela1") ;
>     and TableUpdate(.T., .F., "Tabela2") ;
>     and TableUpdate(.T., .F., "Tabela3")
>  END TRANSACTION
>ELSE
>  ROLLBACK
>ENDIF
>
>
É melhor usar um só TableUpdate(). O TableUpdate() adicional é superfluo.
BEGIN TRANSACTION
IF TableUpdate(.T., .F., "Tabela1") ;
     and TableUpdate(.T., .F., "Tabela2") ;
     and TableUpdate(.T., .F., "Tabela3")
  END TRANSACTION
ELSE
  ROLLBACK
ENDIF
FLUSH
Como nao passa muito tempo entre um TableUpdate() e outro, pode usar um só FLUSH. A idea geral é que não passe muito tempo entre a atualizaçao no disco, e o FLUSH.

Mais se insiste, também pode separar os TableUpdate(); eu só os juntéi pra ter menos código.
BEGIN TRANSACTION
local llSuccess
llSuccess = TableUpdate(.T., .F., "Tabela1")
FLUSH
if llSuccess
  llSuccess = TableUpdate(.T., .F., "Tabela2")
  FLUSH
endif
if llSuccess
  llSuccess = TableUpdate(.T., .F., "Tabela3")
  FLUSH
endif
if llSuccess
  END TRANSACTION
else
  ROLLBACK
endif
O ROLLBACK anulará todos os cambios às tres tabelas.

Hilmar.
FLUSH
Difference in opinions hath cost many millions of lives: for instance, whether flesh be bread, or bread be flesh; whether whistling be a vice or a virtue; whether it be better to kiss a post, or throw it into the fire... (from Gulliver's Travels)
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform