Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The old EOF() and REPLACE gotcha
Message
De
19/10/1999 13:03:35
 
 
À
19/10/1999 09:25:55
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00278126
Message ID:
00278299
Vues:
15
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform