Board index » delphi » Using the IDENTITY with an UpdateSQL Component.

Using the IDENTITY with an UpdateSQL Component.

I use a TUpdateSQL component and on the Insert I call a stored procedure
like this

EXEC gsp_InsertReader :DeviceID, :Caption

After I call ApplyUpdates I need the IDENTITY value stored in :DeviceID as
this is an OUTPUT parameter in the stored procedure.  Is there any way to do
this?

Barry

 

Re:Using the IDENTITY with an UpdateSQL Component.


if you are using  MsSQL check global variable @@Identity.  Personaly i
recomend you not use identitys, for me is better to call a sotred procedure
to obtain the next posible value before the row is inserted.

cheers.

--
Visita nuestra pgina en www.constructoradesoftware.com
Barry Velasquez <barr...@narushka.com> escribi en el mensaje de noticias
3947afba@dnews...

Quote
> I use a TUpdateSQL component and on the Insert I call a stored procedure
> like this

> EXEC gsp_InsertReader :DeviceID, :Caption

> After I call ApplyUpdates I need the IDENTITY value stored in :DeviceID as
> this is an OUTPUT parameter in the stored procedure.  Is there any way to
do
> this?

> Barry

Re:Using the IDENTITY with an UpdateSQL Component.


I know about @@Identity.  However, how do you get it after the ApplyUpdates
when using Cached Updates?  Basically I have a TQuery that is set to Cached
Updates and it has an UpdateObject.  The UpdateObjects Insert SQL EXEC's the
Stored Procedure.  One of the parameters is an Output parameter.  Is there a
way to return this Output parameter and use it after the ApplyUpdates call?

Can you use an Output Parameter with a TQuery component?  It seems that when
I try this, I always get a 0.

"Ing. Sami Casab." <sca...@constructoradesoftware.com> wrote in message
news:3947ba3f@dnews...

Quote
> if you are using  MsSQL check global variable @@Identity.  Personaly i
> recomend you not use identitys, for me is better to call a sotred
procedure
> to obtain the next posible value before the row is inserted.

> cheers.

> --
> Visita nuestra pgina en www.constructoradesoftware.com
> Barry Velasquez <barr...@narushka.com> escribi en el mensaje de noticias
> 3947afba@dnews...
> > I use a TUpdateSQL component and on the Insert I call a stored procedure
> > like this

> > EXEC gsp_InsertReader :DeviceID, :Caption

> > After I call ApplyUpdates I need the IDENTITY value stored in :DeviceID
as
> > this is an OUTPUT parameter in the stored procedure.  Is there any way
to
> do
> > this?

> > Barry

Re:Using the IDENTITY with an UpdateSQL Component.


Quote
Ing. Sami Casab. wrote in message <3947ba3f@dnews>...
>if you are using  MsSQL check global variable @@Identity.  Personaly i
>recomend you not use identitys, for me is better to call a sotred procedure
>to obtain the next posible value before the row is inserted.

>cheers.

>--

Take care using @@Identity.  It returns the last identity field updates by
your transaction, including any triggers that might get called.  Just
because you don't have triggers today doesn't mean someone won't add one and
break your function.

I also recomment using a seed table approach.

Naren

Re:Using the IDENTITY with an UpdateSQL Component.


Hi,

I've made a component (a TRXQuery descendant) just for this purpose. It has
some restrictions (like the corresponding inserting SP parameter names
should match original query field names) but I use it OK in production and
can mail it to you if you're interested.

Regards,

Alex Ehrlich

Quote
Barry Velasquez wrote in message <3947d888@dnews>...
>I know about @@Identity.  However, how do you get it after the ApplyUpdates
>when using Cached Updates?  Basically I have a TQuery that is set to Cached
>Updates and it has an UpdateObject.  The UpdateObjects Insert SQL EXEC's
the
>Stored Procedure.  One of the parameters is an Output parameter.  Is there
a
>way to return this Output parameter and use it after the ApplyUpdates call?

>Can you use an Output Parameter with a TQuery component?  It seems that
when
>I try this, I always get a 0.

>"Ing. Sami Casab." <sca...@constructoradesoftware.com> wrote in message
>news:3947ba3f@dnews...
>> if you are using  MsSQL check global variable @@Identity.  Personaly i
>> recomend you not use identitys, for me is better to call a sotred
>procedure
>> to obtain the next posible value before the row is inserted.

>> cheers.

>> --
>> Visita nuestra p?gina en www.constructoradesoftware.com
>> Barry Velasquez <barr...@narushka.com> escribi? en el mensaje de noticias
>> 3947afba@dnews...
>> > I use a TUpdateSQL component and on the Insert I call a stored
procedure
>> > like this

>> > EXEC gsp_InsertReader :DeviceID, :Caption

>> > After I call ApplyUpdates I need the IDENTITY value stored in :DeviceID
>as
>> > this is an OUTPUT parameter in the stored procedure.  Is there any way
>to
>> do
>> > this?

>> > Barry

Other Threads