Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Samir H.
  Where is Samir H.?
 Yogyakarta
 Indonesia
 Samir H.
 To: sri kishan
  Where is sri kishan?
 
 India
 sri kishan
 Tags
Subject: RE: how we can update record with one sql
Thread ID: 310834 Message ID: 310865 # Views: 29 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: General VFP Topics
Date: Sunday, June 26, 2011 10:49:14 AM         
   


I'd say it's the same. Personally, I use method 2.

> i have seen single sql in foxite but i did not remember the name of the thread.
>
> i think that was posted by Rahul
>
>
>  *** method 1
> 
> select table1.pk from table1 where table1.pk=table2.pk into curs tempcursor
> do case
> case _tally>0
> update ...
> otherwise
> insert ...
> endcase
> 
> 
> *** method 2
> 
> update table1 set table1.filed1=table2.field1 where table1.pk=table2.pk
> if _tally=0
>    insert into table1 (field1) select (field1) from table2 where ...
> endif
>  
> 

>
> which is best from the above 2
>
> Regards
>
>
>
>
> >
> > I guess you cannot because UPDATE and INSERT do two different things. What you could do is a SELECT to check if there is such a record, then a IF-ELSE-ENDIF, with either a Update or a Insert.
> >
> > Regards
> > Samir



Regards
Samir

ENTIRE THREAD

how we can update record with one sql Posted by sri kishan @ 6/25/2011 7:47:45 PM
RE: how we can update record with one sql Posted by Stefan Wuebbe @ 6/25/2011 8:27:20 PM
RE: how we can update record with one sql Posted by sri kishan @ 6/25/2011 8:50:01 PM
RE: how we can update record with one sql Posted by Samir H. @ 6/25/2011 8:33:37 PM
RE: how we can update record with one sql Posted by sri kishan @ 6/26/2011 8:11:20 AM
RE: how we can update record with one sql Posted by Samir H. @ 6/26/2011 10:49:14 AM
RE: how we can update record with one sql Posted by Anders Altberg @ 6/25/2011 11:27:29 PM