Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Convert command into sql query
Message
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01281878
Message ID:
01281918
Views:
6
>
>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
Previous
Reply
Map
View

Click here to load this message in the networking platform