Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Numerical overflow
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00628980
Message ID:
00629060
Vues:
10
>>>>Hi everybody,
>>>>
>>>>When I'm running insert command (or replace, of some alike commands), if Source file has data, which are greater than the numerical field length in the Destination file, I have an error "Numerical overflow" and program stops its execution. My question is: is it possible to automatically clear the field, which is giving the error (the field in unknown) and process the file silently (may be note the error in error log, but don't stop)?
>>>>
>>>>What would be your suggestions about this, I think, common problem?
>>>>
>>>>Thanks in advance.
>>>
>>>Nadya,
>>>
>>>If your error handler simply does a return when this occurs then processing continues as before. Unfortunately, it's not simple to catch. The only thing that I know of that works in even evaluating numeric overflow is "*" $ TRANSFORM(table.field). I suppose that a field level rule could be used on the insert to blank the field in this instance.
>>
>>Hi George,
>>
>>Field level rule idea sounds interesting. Can you please elaborate more?
>
>Sure, the rule would be simply be NOT ("*" $ TRANSFORM(field)). Of course, this would work only with APPEND BLANK and not INSERT INTO. Anyway, what you would do is create a default value and custom error message indicating the field. Your error handler would then handle the job of retrieving the error message via the AERROR() function and logging it.
>
>I haven't thought it through but an insert trigger might be used similarly.
>
>>It still would not help in case, when the destination table is not a part of a database...
>
>In that case, your error handler would have to parse each numeric field when error 39 occurs, log it and return.

Ok, here is a test error handler, which seems to be sufficient in this case...
LOCAL;
llErr

llErr = .f.
create cursor murks (nField n(1), nField1 n(3), cField C(20))
ON ERROR do myError with error() && llErr=.T.
nField = 100
nField1 = 100
cField = 'Nadya'
append blank
*insert into murks from memvar &&(nField) values (100)
gather memvar

*-----------------
function myError
lparameter tnErrorNum
if m.tnErrorNum = 39 && Numeric overflow
   local lnFields, lnI, lcAlias
   lnFields = afields(laFields) && assuming the table is opened
   lcAlias = alias()
   for lnI=1 to m.lnFields
       if laFields[m.lnI,2]='N' and ;
       "*" $ transform(evaluate(lcAlias+"."+laFields[m.lnI,1])) && This is a field, which gave an error
           =messagebox('Field '+ laFields[m.lnI,1]+" would be blanked because of numeric overflow")
           blank field (laFields[m.lnI,1])
           exit
       endif
   next           
   return
endif
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