Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Sql - Insert
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2000 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01140319
Message ID:
01140360
Views:
16
>Yes, that is the idea.
>
>But all three tables are in Sql Server.

Then you must create a trigger as Jake said, or SP wich will handle this for you., something like:
CREATE PROCEDURE InsertIntoTable3
@Description as varchar(8000) = ''
AS
BEGIN
     DECLARE @lcCode1 AS char(5)
     DECLARE @lcCode2 AS char(5)
     DECLARE @lnError AS int
     BEGIN TRANSACTION
        UPDATE TABLE1 SET @lcCode1 = Code1 = CAST(CAST(Code1 as int)+1 as char(5))
        @lnError = @@ERROR
        IF @lnError = 0
           BEGIN
               UPDATE TABLE2 SET @lcCode2 = Code2 = CAST(CAST(Code2 as int)+1 as char(5))
               @lnError = @@ERROR
               IF @lnError = 0
                  BEGIN
                      INSERT INTO Table3 VALUES (@lcCode1, @lcCode2, @Description)
                      @lnError = @@ERROR
                  END
           END
      IF @lnError = 0
         COMMIT
      ELSE
         ROLLBACK
END
(not tested)
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform