Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
BIG problem with Begin Transaction / EndTransaction / Ro
Message
 
À
15/02/2001 14:47:18
Peter Wagner
Point Informática Ltda.
Limeira, Brésil
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00476437
Message ID:
00476540
Vues:
35
First, this doesn't sound like a situation that really needs to use transactions. Transactions are meant for situations where you need a whole series of records to be saved correctly, or else none of them at all get saved. If you're only trying to save one record, just use TABLEUPDATE() and if that fails, you can either TABLEREVERT() or decide how to handle things.

Now, the real question is, what is this ID code that users are entering? Since it's the only field in the table you show, it doesn't mean much. Normally, you have the program generate an ID that it knows it unique, and users never see. I don't know what you're using this ID field for, but it seems it may not be something that should be entered by users if they're likely to enter duplicates.

>I have BIG problem with Begin Transaction / EndTransaction / Roolback
>
>Table1->
>CREATE TABLE 'TABLE1.DBF' NAME 'TABLE1' (IDCODE N(3, 0) NOT NULL)
>SET COLLATE TO 'GENERAL'
>INDEX ON IDCODE TAG IDCODE CANDIDATE
>
>Im sending a simple sample of a form with 3 buttons ( NEW / SAVE / REVERT ).
>One grid with the values and an textbox where user tipes the value.
>
>In station 1 a user opens form1, and click NEW button
>in station 2 another user opens the same form1 and click NEW button
>and insert a value, saves all when he clicks on SAVE button.
>Supose (3)
>
>At the station 1, the user tipes the Same value (3) and them click in the
>SAVE button of the form, but becomes error 1884, and it Rollback( Good ).
>
>Problem: when the user from station 1 clicks again the SAVE button it Saves
>the value in to the transaction even if the value is duplicated in a CANDIDATE Index
>So I have duplicate value in a Candidate index Field !!
>
>How can I solve this problem, because user needs to time the code, I cant generate
>it like Tastrade sample.
>
>Does someone has an Idea how to handle this simple problem ?
>
>Below is the code of the form.
>
>Before load Method in Environment:
>==============================
>SET MULTILOCKS ON
>SET TALK OFF
>SET SAFETY OFF
>SET REPROCESS TO 1
>SET REFRESH TO 1
>SET DELETED ON
>SET CONFIRM ON
>SET HELP OFF
>SET ESCAPE OFF
>SET NOTIFY OFF
>SET BELL OFF
>SET DATE FRENCH
>SET CONSOLE OFF
>SET CENTURY ON
>SET CENTURY TO 19 ROLLOVER 10
>SET COLLATE TO "GENERAL"
>SET NULLDISPLAY TO ""
>
>Activate of Form1:
>===============
>SELECT TABLE1
>GO TOP
>
>NEW Button:
>===========
>SELECT Table1
>APPEND BLANK
>ThisForm.Refresh()
>ThisForm.txtidcode.SetFocus()
>
>SAVE Button:
>===========
>BEGIN TRANSACTION
>IF TABLEUPDATE(.T.,.F.,"Table1")
>wait window STR(reccount()) + " ok "timeout 1.5
> END TRANSACTION
>ELSE
> ROLLBACK
> wait window STR(reccount()) timeout 1.5
> =AERROR(mverror)
> IF TYPE("mverror")<>"U"
> WAIT WINDOW STR(mverror[1,1]) TIMEOUT 1.5
> ENDIF
>ENDIF
>ThisForm.Refresh()
>
>REVERT Button:
>==============
>=TABLEREVERT(.T.,"Table1")
>ThisForm.Refresh()
>ThisForm.txtidcode.SetFocus()
>
>
>Please could someone help me please !
>
>TIA
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform