Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Understanding REPLACE command - why I don't get the erro
Message
De
09/03/2002 21:58:20
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00630443
Message ID:
00630668
Vues:
20
I understand the problem much better now.

It does sound odd, but the firstthing that I would say is that others' suggestion of using the IN clause of REPLACE looks like it SHOULD fix the problem.

Restating the problem in my own words, it looks like you get UNEXPECTED behaviour when, while executing a REPLACE command one of the WITH operands invokes a function that involves creation of a CURSOR.
The unexpected behaviour is that an expected 'numeric overflow' does NOT occur, yet the field in question is known to have overflowed by the presence of asterisks in the field on later inspection.
The unexpected behaviour happens only in development at this point, while trying to solve the problem that arises periodically, where the 'numeric overflow' DOES occur.

Given that, there are probably other differences between the production environment and development, either within the code itself OR as a function of the VFP IDE.

And I *think* you say below that you HAVE changed the code, first to 'fix a few problems' and later to consolidate some functions. It also sounds like YOU introduced the CURSOR creation at this point.

If that is even close to the situation, then...
1) Maybe the data itself is different between production and development systems;
--- If that is the case then maybe you should use the ORIGINAL CODE with the ORIGINAL data on the development system to see if that gives the same result.
2) If the CURSOR is, indeed, the problem (and it sound to me like it *is* implicated - are you certain that you have reset the correct selected area AND at the correct record every time you leave the function) then maybe you can achieve the same objective using an array.

good luck


>Hi Jim,
>
>As I said, I probably didn't explain the whole problem well, because it's really weird and strange. Here is the whole story: we have an application, called JobControl. This application allows to perform different operations, which in our terminology are called Jobs. We have different kind of jobs: "getting data in" and "getting data out". Getting data out kind of jobs usually consist of three steps: Query, Transformation and Report step.
>
>We have two servers: "Live" server and "Development" server. On the "Live" server we got "Numerical overflow" error, which was followed with VFP error. So we wanted to replicate this problem on Development server in order to demonstrate it to our colleague and let her fix it.
>
>However, to our surprise, we didn't get this error on Development server and the job was ran till completion just fine. Well, in order to simulate this problem we put 1000 in transformation for BedRooms field (which is N(2)) and we still didn't get an error (field had * in each record in output file). We started to search for a reason, I put couple of "set step on" commands in XForm application, observed it few times in debugger, but it never executed Error method of the form...
>
>Well, here is how XForm application works:
>It creates a program with a long replace command like this:
>
>replace y.field1 with field1, y.field2 with UDF1(field2, field3,..),......
>
>where Y is the output file, X - input file and when the replace statement is executed, the selected work area is X.
>
>So, we saved this temp program and ran it in Command window. It didn't produce an Error. Finally my manager with the help of our colleague was able to isolate the UDF, which seemed to be a culprit: GetPrSlInfo.
>
>I looked at the original code, found few problems, fixed it, and this is the current state of the function. I don't see, what could be wrong in this function. It should look in Transaction file for this property and find the previous sale information.
>
>Originally we have 4 (or more) similar functions: GetPrDate, GetPrPrice, GetPrBook, GetPrPage, however, I thought, that it would be better to have one UDF and on each record do a search just once instead of 4 times, as it was originaly. That's how this function came to play.
>
>However, it seems like creating a cursor during replace command somehow changes the behavior of REPLACE command, e.g. it doesn't trigger an error, when it should.
>
>So, do you see, what could be my problem here?
>
>I would appreciate your insights...
>
>===========================================================
>The weirdness, I mentioned, was a different kind:
>
>If I'm sitting on X and run this command: replace y.bedrooms with 10000, y.totrooms with 100000, I sometimes didn't get an error. May be it was related to a fact, what I was at eof in Y...
>
>
>
>>Well, Nadya, I *DID* read the whole message, and a few times too, especially after rading Mike Y's reply to you.
>>
>>Where in your original message did you say that you WANTED the numeric overflow and were not getting it????
>>The statement "...I get this error... I see some other weirdness as well..." suggests to me that it is the error and other weirdness that you are trying to eliminate. I never even came close to assuming that you wanted the error.
>>This explains my first question... what am I missing here? And you didn't answer it here, but I read it in another message you wrote!!!
>>
>>I settled on your topic title as the main issue - Understanding REPLACE command. I must admit that I saw NO connection whatsoever between your title/replace command sample and the full content of the UDF(). You seem to link it to a cursor being created or not, and I think you *may* be jumping to conclusions.
>>
>>I'll leave it now to people who like working with unexplained problems and seemingly unrelated code. There are quite a few here who can, it seems, read the minds of message originators. One of them will find the answer.
>>
>>
>>>Jim,
>>>
>>>I guess, you didn't read my whole message or I didn't explain the problem well. The problem is, what the first time (when the cursor is not yet created), I don't get a "Numerical overflow" problem, as I should. This is a problem, I was trying to detect, and therefore these big numbers are intentional.
>>>
>>>Do you have ideas or could you replicate the problem?
>>>
>>>>What am I missing here????
>>>>
>>>>How does 1000 fit in a N(02) field?... or 10000 in a N(4,1) field???
>>>>
>>>>If you're gonna put code like this out for detecting a problem, the some commentary saying what the objective is might be helpful.
>>>>
>>>>good luck
>>>>
>>>>
>>>>>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:
>>>>>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.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform