Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to verrify an Insert into using Sqlexec
Message
 
 
To
26/04/2000 13:49:27
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00363680
Message ID:
00364096
Views:
30
You asked for the BEST way.....

The best way is to use a stored proc tha handle the insert..

Here is a sample:
CREATE PROCEDURE  customers_add @Name Varchar(50),@newkey INTEGER OUTPUT

AS 

 BEGIN TRANSACTION 

 INSERT INTO Customers(name)
    VALUES (@name)
 SELECT @newKey = @@IDENTITY 

 COMMIT TRANSACTION 
This method of course assumes the use of identity columns...which should be used for primary keys any way. Does @@RowCount work? It appears to. However, if you are looking for the BEST way to handle this, why not reference an environmental variable that specfically deals with new records. If the insert fails, @@Identity evaluates to null. The use of output variables is an extremely effective technique for deterimining success and failure. And, you only need to make 1 call...


>I would like to know the best way to verify if data inserted into a client/server table was committed. I establish a connection and verify the connection. Then, I intert data into the table. This all work fine, I just need to verify the insert.
>
>Thanks, Chris
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform