Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Adding new records to a table
Message
 
À
30/07/1998 17:00:56
John Thomason
King Richard Veterinary Centre
Leicester, Royaume Uni
Information générale
Forum:
Visual FoxPro
Catégorie:
The Mere Mortals Framework
Divers
Thread ID:
00122867
Message ID:
00123723
Vues:
14
>I need to add new records to a table using a method that examines values in existing records and adds a new record if certain criteria are met. What is the best way of doing this in “codebook style”. Do I use INSERT INTO or the built in new() method, fill in the fields and then save the new record?
>
>Any help would be appreciated.
>
>John Thomason

John,

You don't tell us much... But anyway, I seem to understand you're wanting to achieve some sort of batch update.
I use a variation of a cBizObjRetValForm and place a bizobj on it. The bizobj has no controls, it's there just to provide
access to the data. Then in the form DoActions() I do my things. I usually show a progress meter so that users can have
a clue there is something going on. Here is a sample:

LOCAL lnMax, ;
lnNext, ;
i, ;
lnStep, ;
llToast

SELECT v_14
Requery()

lnMax = RECCOUNT()

SCAN
REPLACE lEnfant WITH .F., ;
tDerModif WITH DATETIME()
ENDSCAN

lnNext = GETNEXTMODIFIED(0)

i = 0
lnStep = MAX(INT( lnMax / 100), 1)

BEGIN TRANSACTION
DO WHILE lnNext # 0
GO (lnNext)
IF ! TABLEUPDATE()
llToast = .T.
EXIT
ENDIF
IF MOD ( i , lnStep) = 0
this.cProgressMeter1.RefreshDisplay(i, lnMax)
ENDIF
lnNext = GETNEXTMODIFIED(lnNext)
i = i + 1
ENDDO

this.cProgressMeter1.Reset()

IF llToast
ROLLBACK
TABLEREVERT(.T.)
ErrorMsg(this.cMsgUpdateFailed)
RETURN .F.
ELSE
END TRANSACTION
ENDIF

MESSAGEBOX(DONE_LOC, 64, APPNAME_LOC)
*-- on en reste là pour le moment
RETURN


José
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform