Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
I can use SCOPE_IDENTITY() with INSTEAD OF INSERT on a view?
Message
De
11/06/2003 07:34:07
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Titre:
I can use SCOPE_IDENTITY() with INSTEAD OF INSERT on a view?
Divers
Thread ID:
00798811
Message ID:
00798811
Vues:
87
Hi,

i have one view VW1 defined as join of two tables T1 and T2.

T1 have a 'id' field IDENTITY.
T2 have a 'idRef' field in relation 1-1 to T1.id.

I need INSERT one row on View, and split view fields on T1 and T2.

I define one TRIGGER vw1Insert ON dbo.VW1 INSTEAD OF INSERT AS ....

My problem:
i want new id (identity) value insert into T1 in the trigger.

Because INSERT commands exec on the trigger can fired other trigger or sp that do other INSERT command on other table with identity, i cannot use
@@IDENTITY.

I cannot use IDENT_CURRENT('table_name') because i want lock T1 for INSERT command on other sessions.

I use SCOPE_IDENTITY() but it return NULL!

I think this because view is ambiguos, but i test SCOPE_IDENTITY() with
INSTEAD OF INSERT for a table. result is NULL.

Fabio
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform