Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
INSERT not as maintainable?
Message
De
26/07/2006 16:37:09
Dragan Nedeljkovich (En ligne)
Now officially retired
Zrenjanin, Serbia
 
 
À
26/07/2006 16:19:48
Mike Yearwood
Toronto, Ontario, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
01140411
Message ID:
01140449
Vues:
28
>>-From my POV insert syntax is better. You can't get the list out of sync if you don't do that on purpose.
>
>It is easy to make mistakes. Humans are taught to read English Left to Right and Top to Bottom. INSERT separates the fields from the values breaking the reading pattern and increasing the mistakes.

I tend to agree here - with more than just a few fields, it's easy to develop eye fatigue.

My solution is insert from name. I don't mind a Createobject("empty") and a series of addproperty() calls - these are again just single-liners (i.e. one line per field, not two), and have one advantage: if you insist on insert...values, what if you actually don't know whether it'll be an insert or an update? Suppose your code checks for primary key first, and then inserts or updates, depending on the result.

Your code may develop into a lengthy sausage:
if lUpdating
   update mytable set;
      field1=value1  ;
      ,   field2=value2;
...
   where pk=m.lPK
else
   insert into mytable (;
      field1   ;
      ,   field2   ;
...
      )   ;
   values ;
      (value1   ;
      ,   value2
 ....
      )
endif<pre>

whereas using a record object, we have
<pre>loRec=createobject("empty")
addproperty(loRec, "field1", value1)
addproperty(loRec, "field2", value2)
...
select myalias
if lUpdating
   gather name loRec memo
else
   insert into myalias from name lorec memo
endif
.

There's no multiline statement here which has to be carefully maintained.

back to same old

the first online autobiography, unfinished by design
What, me reckless? I'm full of recks!
Balkans, eh? Count them.
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform