Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Convert command into sql query
Message
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
01281878
Message ID:
01281918
Vues:
7
>
>select * from student where scode=zscode and lcode=zlcode and sec=zsec and admtd=1
>into cursor curToProcess nofilter
>select * from curToProcess left join ExamTran ex on ... where ex.code is NULL into cursor curToInsert nofilter
>
>insert into ExamTran (code) select code from curToInsert
>update examtran
>set (all your changes)
>from curToProcess inner join ExamTran on curToProcess.code = ExamTran.code
>
>
>From the top of my head and not tested.

Perhaps this can be simplified a bit more. First do update, then insert with updates implied for the codes not found.

Also there is a trick if code is a PK:
try
  insert .... (with changes)
catch
  update with changes
endtry
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform