Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GO to a negative recno in a optimistic table buffered cu
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 6 SP5
Divers
Thread ID:
01031593
Message ID:
01031787
Vues:
10
In the complicated form I have the following in the PreSaveHook method of biz obj:
IF THIS.IsNew()
	THIS.ResetPrimaryFlag() && Reset previous records Primary flag to 0
	REPLACE cPointer_fk WITH v_patients.cPatients_pk, ;
			cPointer_table_name WITH 'PATIENTS', ;
			cUsgrlink_fk WITH THISFORM.cUsgrlink_fk , ;
			iPrimary_flag WITH 1
	this.cAction_Code = "AD"		
ELSE
	REPLACE cUsgrlink_fk WITH THISFORM.cUsgrlink_fk
	this.cAction_Code = "CH"
ENDIF
Where ResetPrimaryFlag method is:
*---------------------- Location Section ------------------------
*   Library: 	Abizness.vcx
*   Class: 		Abizobj
*   Method: 	Resetprimaryflag()
*----------------------- Usage Section --------------------------
*)  Description:
*)

*   Scope:      Public
*   Parameters:
*$  Usage:
*$
*   Returns:
*--------------------- Maintenance Section ----------------------
*   Change Log:
*       CREATED 	07/07/2005 - WGB
*		MODIFIED
*----------------------------------------------------------------
LOCAL loSelect, lnCurRec, lcAlias

loSelect = THIS.SelectAlias()

IF RECCOUNT() > 1
	lnCurRec = RECNO() && Save the current record

	lcAlias = ALIAS() && primary view of the biz object

*REPLACE iPrimary_flag WITH 0 FOR iPrimary_flag = 1

	UPDATE (lcAlias) SET iPrimary_flag = 0 WHERE iPrimary_flag = 1

	GOTO lnCurRec && Return to the record
ENDIF
I found, that this code is not reliable and in some cases is not working at all. I can not see, what exactly is wrong with it.

Anyway, I switched to the following: (in different biz obj)
IF THIS.IsNew()
*	THIS.ResetPrimaryFlag() && Reset previous records Primary flag to 0
        local lcEmployers_pk
lcEmployers_pk = cEmployers_pk && Save new record's PK
	REPLACE cPointer_fk WITH v_patients.cPatients_pk, ;
			cPointer_table_name WITH 'PATIENTS', ;
			cUsgrlink_fk WITH THISFORM.cUsgrlink_fk , ;
			iPrimary_flag WITH iif(cEmployers_pk == m.lcEmployers_pk,1,0) all
ELSE
	REPLACE cUsgrlink_fk WITH THISFORM.cUsgrlink_fk
ENDIF
and this seems to work fine so far.

But why the combination of UPDATE & REPLACE is not working?
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform