Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Begin Transation e TableUpdate
Message
De
26/11/2002 16:12:08
Hilmar Zonneveld
Independent Consultant
Cochabamba, Bolivie
 
 
À
26/11/2002 10:44:52
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00726899
Message ID:
00727299
Vues:
18
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)
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform