Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Insert not inserting no more
Message
De
24/08/2014 14:54:00
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows 7
Network:
Windows NT
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01606233
Message ID:
01606321
Vues:
55
Thanks for the suggestion Hugo.

>Hi Denis,
>
>I agree with Mike and Tore that it would be better if you find the root of the problem, but may I suggest an alternative code?
>
>If I understood correctly your code you always want to have 25 records in the cursor, so, why don't you move the FOR loop to the top, always initializing it to the 25 records, and then in the scan you remove the insert and just do the replace, something like:
>
>
>CREATE CURSOR cÉtap1 (Séquence n(3), DescServ C(50), CléPrimaire I)
>
>* Here some code I didn't include. It will put records in the cursor cÉtap1
>
>CREATE CURSOR ;
>	cRapp ( Entete1 c(50),  Entete2  c(50),  Entete3  c(50), Entete4  c(50),;
>        
>        * And a bunch of other fields.
>)
>
>SELECT Séquence, DescServ, CléPrimaire ;
>FROM cÉtap1 ;
>ORDER BY DescServ ;
>INTO CURSOR cSuiviServ READWRITE 
>
>SELECT ... INTO CURSOR cEmp1Temp READWRITE 
>
>IF _tally = 0
>	DO FORM ts_messagebox WITH I('Pas de données à imprimer.')
>ELSE
>	FOR nI = 1 TO 25
>		INSERT INTO cRapp ;
>			(;
>			Entete1,;
>			Entete2,;
>			Entete3,;
>			Entete4;
>			);
>			VALUES ;
>			(;
>			cEntete1,;
>			cEntete2,;
>			cEntete3,;
>			cEntete4;
>			)
>	ENDFOR 
>	nTotLigne = 0
>	SCAN  	
>		nTotLigne = nTotLigne + 1
>
>*		INSERT INTO cRapp ( NomServ1) VALUES ("")
>		SELECT cSuiviServ
>		nI = 0
>		SCAN
>			ni = nI + 1
>			cNi = ALLTRIM( STR( ni))
>			cReplace = "Replace NomServ" + cNi + " with cSuiviServ.DescServ in 'cRapp'"
>			&cReplace 	
>		ENDSCAN 
>
>		replace Entete1 WITH cEntete1 IN "cRapp"
>		replace Entete2 WITH cEntete2 IN "cRapp"
>		replace Entete3 WITH cEntete3 IN "cRapp"
>		replace Entete4 WITH cEntete4 IN "cRapp"
>		
>		replace date WITH cEmp1Temp.DateRv IN "cRapp"
>		Replace NomProf WITH I("Professeur") + ": " + ALLTRIM( cEmp1Temp.NomProf) IN "cRapp"
>		replace Heur WITH cEmp1Temp.HeurDebu IN "cRapp"
>		replace NomClient WITH cEmp1Temp.NomClient IN "cRapp"
>		replace Tél WITH cEmp1Temp.Téléphone IN "cRapp"
>
>		nPos = cEmp1Temp.Séquence
>		cReplace = "replace LignServChoisiPos" + ALLTRIM( STR( nPos)) +;
>			" with 'X' in 'cRapp'"	
>		&cReplace		
>
>		SKIP IN cRapp
>			
>		SELECT cEmp1Temp
>	ENDSCAN 
>	
>
>        * Here again I didn't copy the code because anyway the insert didn't succeed.
>
>
>I also think that one replace (comma separated pairs of fields and values) would give you better performance.. Ah, also you do not need macros, ie
>
>
>replace LignServChoisiPos" + ALLTRIM( STR( nPos)) +			" with 'X' in 'cRapp'	* can be changed to:
>
>replace (LignServChoisiPos" + ALLTRIM( STR( nPos))) with 'X' in 'cRapp'
>
>
>
>(I know I am not helping with the original problem but nitpicking, sorry)
*******************************************************
Save a tree, eat a beaver.
Denis Chassé
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform