Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 To: Leonard Trevor
  Where is Leonard Trevor?
 Edinburgh
 United Kingdom
 Leonard Trevor
 Tags
Subject: RE: Combo boxes behaving weirdly in sql using SPT
Thread ID: 104473 Message ID: 104557 # Views: 2 # Ratings: 1
Version: Visual FoxPro 6 Category: Errors & Debugging
Date: Thursday, August 17, 2006 3:48:53 PM         
   


> Point of Information
>
> How do you insert into 2 datafiles at the same time using ths
insert
command in spt on a form
>
>
> I'm using vfp6 do you have the syntax
>
> TEXT TO _____ NOSHOW TEXTMERGE
> .......
> .......
>
> ENDTEXT


You cannot do this with a single command. You need to use transactions. Place the a series of INSERT commands within a BEGIN TRANSACTION/END TRANSACTION construct and check the results of your UPDATE command. If any UPDATE command fails, you then issue a ROLLBACK. This ensures that the records are added only if all UPDATEs succeed.
*   Create your two update commands
TEXT TO SQLScript1 NOWSHOW TEXTMERGE PRETEXT 15
  INSERT INTO Tbl1 ...
ENDTEXT
TEXT TO SQLScript2 NOWSHOW TEXTMERGE PRETEXT 15
  INSERT INTO Tbl2 ...
ENDTEXT
*   Begin your transaction
BEGIN TRANSACTION
   &SQLScript1   && insert into table 1
   llSuccess = TABLEUPDATE()  && Check the update
   IF llSuccess 
      &SQLScript2  && insert into table 2
      llSuccess = TABLEUPDATE()  && Check the update
      IF llSuccess
         && all updates worked
      ELSE
         ROLLBACK  && Table 2 did not update
         && do something
      ENDIF
   ELSE
      ROLLBACK   && Table1 did not update
      && do something
   ENDIF
END TRANSACTION  && both tables updated so end the transaction and commmit the additions

Ken
You shall know the truth - and the truth shall set you free. (John 8:33)

ENTIRE THREAD

Combo boxes behaving weirdly in sql using SPT Posted by Leonard Trevor @ 8/16/2006 9:36:42 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Borislav Borissov @ 8/16/2006 9:52:55 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Leonard Trevor @ 8/16/2006 11:27:36 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Borislav Borissov @ 8/17/2006 9:19:07 AM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Leonard Trevor @ 8/17/2006 11:07:00 AM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Borislav Borissov @ 8/17/2006 11:10:36 AM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Leonard Trevor @ 8/17/2006 1:17:47 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Borislav Borissov @ 8/17/2006 1:20:09 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Leonard Trevor @ 8/17/2006 2:01:24 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Borislav Borissov @ 8/17/2006 2:18:04 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Leonard Trevor @ 8/17/2006 2:53:29 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Borislav Borissov @ 8/17/2006 3:04:47 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Leonard Trevor @ 8/17/2006 4:55:14 PM
RE: Combo boxes behaving weirdly in sql using SPT Posted by Ken Murphy @ 8/17/2006 3:48:53 PM