Information générale
Catégorie:
The Mere Mortals Framework
>>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é
José,
I had made a mistake that prevented a PK being generated. The confusion had me barking up the wrong tree hence the obscure question.
Thanks for your help.
John Thomason
Précédent
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement