Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding REPLACE command - why I don't get the error?
Message
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Understanding REPLACE command - why I don't get the error?
Divers
Thread ID:
00630443
Message ID:
00630443
Vues:
55
Hi everybody,

Here is a problem, which we're experiencing:

we have input table aliased as X and output table aliased as Y.

Here is replace command, we're trying, sitting on X:
replace y.TotRooms with 10000, y.BedRooms with 1000, ;
y.PRSLDATE WITH GetPrSlInfo(X.PROPID, X.SOURCE, X.DATE,'Date')

where TotRooms is N (4.1) and Bedrooms N(2).

Here is the code for GetPrSlInfo UDF:
********************************************************************************
function GetPrSlInfo
*  Description.......: Function returns the previous sale info if it exists
*  Calling Samples...: GetPrSlInfo(PROPID,SOURCE,DATE,"Date","C",8)
*  Parameter List....: tnPropid, tcSource, tdDate, tcFieldName, tcRetType (Optional), tnNumChar (Optional)
*  Created by........: Nadya Nosonovsky 08/15/01 12:04:59 PM
*  Modified by.......: Nadya Nosonovsky 08/15/01 12:05:02 PM
********************************************************************
lparameter tnPropId, tcSource, tdDate, tcFieldName, tcRetType, tnNumChar, lnRecno, lnReccount
local lnSelect, lVar
lnSelect=select()
lnRecno = recno() && Assuming we're sitting on the correct file
lnReccount = reccount()
if !used('curPrevSlInfo')
	select 0
	create cursor curPrevSlInfo (RecNum I, date D, Price I, Book I, page I)
	append blank	
endif
if curPrevSlInfo.RecNum <> m.lnRecno
	replace RecNum with m.lnRecno in curPrevSlInfo
*   lVar=CreateEmptyVar(m.tcFieldName,'TranMstr')
	if m.tcSource = "S" and seek(str(m.tnPropId,9)+dtos(m.tdDate),"TranMstr","TrxnHist")
		select TranMstr
		set order to TrxnHist
		if !eof()
			skip
			if TranMstr.PropID = m.tnPropId
				do while TranMstr.PropID = m.tnPropId
					if TranMstr.source = "S" and TranMstr.date < m.tdDate					        
					        replace Date with TranMstr.Date, ;
					                Price with TranMstr.Price, ;
					                Book with TranMstr.Book, ;
					                Page with TranMstr.Page in curPrevSlInfo
*!*							scatter memvar
*!*							insert into curPrevSlInfo from memvar
						exit
					endif
					if !eof()
						skip
					else
						exit
					endif
				enddo
			endif
		endif
	endif
endif
lVar = evaluate('curPrevSlInfo.'+ m.tcFieldName)
if m.lnRecno=m.lnReccount && Last record
   use in curPrevSlInfo
endif
select (m.lnSelect)
if !empty(m.tcRetType)
	if vartype(m.lVar)<>m.tcRetType
		return ConvertType(m.lVar,m.tcRetType,m.tnNumChar)
	endif
else
	return m.lVar
endif
I ran couple of tests in command window. If I ran it first time, when curPrevSlInfo is not created, I didn't get a Numeric Overflow error. The second time I run my test5 program, I get this error... I see some other weirdness as well. When I run this transformation for multiple records, it doesn't produce errors and the job runs till completion...

As a workaround I can change this program to either create public variables (and release them at last record) or create public array, or add array to the _screen (or _vfp) object instead of using cursor. I guess, we probably can not create a cursor during replace command...

Anyway, it's very weird... Windows 95 VFP6 SP4.

Can you please replicate my findings and suggest a workaround?

Thanks a lot in advance.
If it's not broken, fix it until it is.


My Blog
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform