Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to verrify an Insert into using Sqlexec
Message
 
À
26/04/2000 13:49:27
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00363680
Message ID:
00364096
Vues:
32
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform