Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
The most elegant and readable way (and efficient)
Message
De
10/12/2005 09:30:04
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/12/2005 09:09:49
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01076714
Message ID:
01076870
Vues:
16
>Hi,
>
>Sergey's way is probably efficient enough, but on the asssumption that oodles
>of records might have to be modified, I'ld prepare a replace-string
>pseudo code
>
>for every field in both tables and not in exclude list
>   tcRep = iif(empty(tcRep), "" ,tcRep + ", ") + fieldname + " with iif(empty(target.fieldname) and !empty(source.fieldname), source.fieldname,  target.fieldname)"
>
>and later call
>replace all &tcRep for seek(target.PK, SourceAlias, SourceTag)
>
>which makes just one call to makroexpansion for the whole table.
>Since the whole processing of empty fields is handed off to the runtime,
>it should be faster than checking in a vfp loop after positioning via code.
>
>Also, it is immune against tables with different fcount() and so on -
>but requires same field names and is a bit more work. depends on your data <g>.
>
>
>
>my 0.02 EUR
>
>thomas

Thomas,
Then adding another 0.01 EUR wouldn't hurt:)
I agree building a string and doing a single pass would be better but I actually see danger in both approaches. Empty() function that is:)
-Field(s) might be supporting null
-Field type might be dangerous for this logic < g > ie: a logical. Is .f. empty or .t. then:)
If these problems were not an issue Max() might be used as a shortcut with most datatypes:

tcRep = iif(empty(tcRep), "" ,tcRep + ", ") + fieldname + " with iif(empty(target.fieldname) and !empty(source.fieldname), source.fieldname, target.fieldname)"

tcRep = iif(empty(tcRep), "" ,tcRep + ", ") + fieldname + " with max(source.fieldname, target.fieldname)"

Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform