Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Return @@Identity (yet again)
Message
De
18/10/2004 19:44:17
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Return @@Identity (yet again)
Divers
Thread ID:
00952482
Message ID:
00952482
Vues:
51
Hi All,

I know this subject has been beaten to death on these boards, but I have gone through old posts on this forum and others and just cannot get this to work. It's using SQL Stored Procedures through the CursorAdapter class.

Here's the SQL Stored Proc:
CREATE PROCEDURE Attribute_InsProc
       ( @Description NVARCHAR(30), @id int Output )
AS
BEGIN
   BEGIN TRAN
      INSERT INTO Attribute
             ( Description )
      VALUES ( @Description )
     Select @id = SCOPE_IDENTITY( )
      IF (@@error!=0)
         BEGIN
         RAISERROR  20000  'Attribute_InsProc: Cannot insert because primary key value not found in Attribute'
         ROLLBACK TRAN
         RETURN(1)
      END
   COMMIT TRAN
END
Here is the CursorAdapter InsertCmd value:
Exec Attribute_InsProc @Description=?ca_Attribute.Description,@id=?ca_Attribute.kAttribute
It is my understandig that the new ID value should be placed in kAttribute. I append a record and TableUpdate(.T.). TableUpdate executes OK but the new ID value is not in the cursor. Any ideas? Did I go wrong somewhere?

Aloha,

James
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform