Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
The old EOF() and REPLACE gotcha
Message
From
19/10/1999 13:03:35
 
 
To
19/10/1999 09:25:55
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00278126
Message ID:
00278299
Views:
17
>Hi All,
>
>Went crazy with a REPLACE problem until I realized I was being bitten by an old problem. Thought I would post what was happening FYI:
>
>Assume two tables, invheader and invdetail. invheader has 1 record and invdetail has none. The following statement won't work:
>
>SELECT invdetail
>REPLACE invheader.invno WITH "00001"
>
>No replacement is made because the current alias, invdetail, is at EOF() (no records), even though invheader has a record and this is a valid statement. The following WILL work:
>
>SELECT invheader
>REPLACE invheader.invno WITH "00001"
>
>Sometime this won't be as obvious as you won't have a SELECT statement to make the ALIAS() apparent.

Believe it or not, though annoying, this is one of those that qualifies as "By design"

A REPLACE statement takes two optional clauses: a FOR clause, and an IN clause.

If you leave out the IN clause, the replace assumes it is working on the current alias. If you leave out the FOR clause, the replace assumes it shall execute the command once for the current record in the current alias (as opposed to once for every record in the current alias that meets the specified condition). So, if you leave out the IN clause, VFP operates on the current table, and if the current table does not have a current record (EOF()), the command will not execute.

Call it a bug if you will, but this "bug" won't ever be fixed.
Erik Moore
Clientelligence
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform