Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Numeric overflow
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows 2000 SP4
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Divers
Thread ID:
01236596
Message ID:
01236604
Vues:
21
This message has been marked as a message which has helped to the initial question of the thread.
>hi all,
>I have a problem updating a writable cursor. basically it goes like this
>
>sele *, 0.00 as field1, 0.00 as field2 where.. into cursor temp1 readwrite
>do while not eof
>
>    repl field1 with numeric_value * 2.5
>    repl field2 with field1 * other_numeric_field
>
>    loop
>enddo
>
>i get a numeric overflow error on these two lines sometimes but i have no idea why, any ideas?
>~M

You have more digits than your field allows, e.g. the result may be 1234.5678 and you have only 9.99 (or may be you're dividing by 0)?

I had the following old code to trap for this kind of problems:
function CurErrHandler
lparameter tnErrorNum
if not 'vfpevent.fll' $ lower(set('library'))
	set library to vfpEvent.fll additive
endif
if m.tnErrorNum = 39 && Numeric overflow
	local lnFields, lnI, lcAlias, lnRecord, lnResult
	lcAlias = alias()
	lnFields = afields(laFields,m.lcAlias) && assuming the table is opened
	lnRecord = recno(m.lcAlias)
	for lnI=1 to m.lnFields
		if inlist(laFields[m.lnI,2],'N','I','B','Y','F') and ;
				"*" $ transform(evaluate(m.lcAlias+"."+laFields[m.lnI,1])) && This is a field, which gave an error
			lnResult =  EventMBox('Field '+ laFields[m.lnI,1]+" would be blanked because of numeric overflow "+ ;
				chr(13)+"on the record "+transform(m.lnRecord)+" in file "+dbf(m.lcAlias)+ ;
				chr(13)+"Do you want to continue the appending process?", ;
				MB_YESNO + MB_ICONQUESTION + MB_DEFBUTTON1, ;
				"Error is encountered!", ;
				"&Proceed", ;
				"&Stop", "")
			blank field (laFields[m.lnI,1])
			pnNumberOfProblems = m.pnNumberOfProblems + 1 && Increment number of problems

			if m.lnResult = IDNO && Stop 
				plHalt = .t. && Stop the process
			endif
		endif
	next
	return
else
	error m.tnErrorNum && produce an error and handle it by normal error Handler
endif
If it's not broken, fix it until it is.


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

Click here to load this message in the networking platform