PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Hébergement serveur > ms.sqlserver.server > insert trigger calls stored proc
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
insert trigger calls stored proc

Réponse
 
LinkBack Outils de la discussion
Vieux 01/09/2008, 13h40   #1
krostpupe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut insert trigger calls stored proc

Hello all!

I have a insert trigger that should sent the responding column or columns to
a stored procedure on another server. My guess is that only one row of data
is transferred to the stored procedure. Of course i want all returning rows
to be transferred!
Trigger Code is:

CREATE TRIGGER INS_045004 ON [dbo].[ttdsls045004]
FOR INSERT
AS

set nocount on

declare @Status as varchar(30)
declare @Auftragsnummer as int
declare @Auftragsposition as int




BEGIN DISTRIBUTED TRANSACTION


SELECT @Auftragsnummer = t_orno, @Auftragsposition = t_pono,
@Status = CASE

WHEN t_ssls = 1 THEN 'Auftragsbestätigung gedruckt'

WHEN t_ssls = 8 THEN 'Auftrag im Vertrieb'

WHEN t_ssls = 3 THEN 'Auftrag am Lager'

WHEN t_ssls = 4 THEN 'Lieferschein gedruckt'

WHEN t_ssls = 6 THEN 'Rechnung gedruckt'

WHEN t_ssls = 7 THEN 'Auftrag abgeschlossen'

ELSE 'Keine Statusinformationen verfügbar'

END
FROM inserted


exec [172.16.0.100].b2bdata.dbo.psetStatus_Vertr
@STATUS,
@AUFTRAGSNUMMER,
@AUFTRAGSPOSITION




COMMIT TRANSACTION





The Code of the stored procedure:

CREATE PROCEDURE psetStatus_Vertr
(
@STATUS as varchar (30),
@AUFTRAGSNUMMER as int,
@AUFTRAGSPOSITION as int
)

AS


update STATUS set STATUS_VERTR = @STATUS
where AUFTRAGSNUMMER = @AUFTRAGSNUMMER and AUFTRAGSPOSITION =
@AUFTRAGSPOSITION
GO



Any would be appreciated! Thanks in advance!




















  Réponse avec citation
Vieux 01/09/2008, 13h50   #2
Uri Dimant
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: insert trigger calls stored proc

Hi
Yes ,as your trigger does not handle multi-inserted rows.
In you case you will have to loop thru the inserted table and send the
data


"krostpupe" <krostpupe@discussions.microsoft.com> wrote in message
news:A565A6F6-948C-4FE2-B0FB-1A558025104B@microsoft.com...
> Hello all!
>
> I have a insert trigger that should sent the responding column or columns
> to
> a stored procedure on another server. My guess is that only one row of
> data
> is transferred to the stored procedure. Of course i want all returning
> rows
> to be transferred!
> Trigger Code is:
>
> CREATE TRIGGER INS_045004 ON [dbo].[ttdsls045004]
> FOR INSERT
> AS
>
> set nocount on
>
> declare @Status as varchar(30)
> declare @Auftragsnummer as int
> declare @Auftragsposition as int
>
>
>
>
> BEGIN DISTRIBUTED TRANSACTION
>
>
> SELECT @Auftragsnummer = t_orno, @Auftragsposition = t_pono,
> @Status = CASE
>
> WHEN t_ssls = 1 THEN 'Auftragsbest?tigung gedruckt'
>
> WHEN t_ssls = 8 THEN 'Auftrag im Vertrieb'
>
> WHEN t_ssls = 3 THEN 'Auftrag am Lager'
>
> WHEN t_ssls = 4 THEN 'Lieferschein gedruckt'
>
> WHEN t_ssls = 6 THEN 'Rechnung gedruckt'
>
> WHEN t_ssls = 7 THEN 'Auftrag abgeschlossen'
>
> ELSE 'Keine Statusinformationen verf?gbar'
>
> END
> FROM inserted
>
>
> exec [172.16.0.100].b2bdata.dbo.psetStatus_Vertr
> @STATUS,
> @AUFTRAGSNUMMER,
> @AUFTRAGSPOSITION
>
>
>
>
> COMMIT TRANSACTION
>
>
>
>
>
> The Code of the stored procedure:
>
> CREATE PROCEDURE psetStatus_Vertr
> (
> @STATUS as varchar (30),
> @AUFTRAGSNUMMER as int,
> @AUFTRAGSPOSITION as int
> )
>
> AS
>
>
> update STATUS set STATUS_VERTR = @STATUS
> where AUFTRAGSNUMMER = @AUFTRAGSNUMMER and AUFTRAGSPOSITION =
> @AUFTRAGSPOSITION
> GO
>
>
>
> Any would be appreciated! Thanks in advance!
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



  Réponse avec citation
Vieux 01/09/2008, 14h05   #3
krostpupe
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: insert trigger calls stored proc

Thank you for your fast reply!

Unfortunatly i don´t know exactly what you mean! How can i loop through the
inserted table?

"Uri Dimant" wrote:

> Hi
> Yes ,as your trigger does not handle multi-inserted rows.
> In you case you will have to loop thru the inserted table and send the
> data
>
>
> "krostpupe" <krostpupe@discussions.microsoft.com> wrote in message
> news:A565A6F6-948C-4FE2-B0FB-1A558025104B@microsoft.com...
> > Hello all!
> >
> > I have a insert trigger that should sent the responding column or columns
> > to
> > a stored procedure on another server. My guess is that only one row of
> > data
> > is transferred to the stored procedure. Of course i want all returning
> > rows
> > to be transferred!
> > Trigger Code is:
> >
> > CREATE TRIGGER INS_045004 ON [dbo].[ttdsls045004]
> > FOR INSERT
> > AS
> >
> > set nocount on
> >
> > declare @Status as varchar(30)
> > declare @Auftragsnummer as int
> > declare @Auftragsposition as int
> >
> >
> >
> >
> > BEGIN DISTRIBUTED TRANSACTION
> >
> >
> > SELECT @Auftragsnummer = t_orno, @Auftragsposition = t_pono,
> > @Status = CASE
> >
> > WHEN t_ssls = 1 THEN 'Auftragsbest?tigung gedruckt'
> >
> > WHEN t_ssls = 8 THEN 'Auftrag im Vertrieb'
> >
> > WHEN t_ssls = 3 THEN 'Auftrag am Lager'
> >
> > WHEN t_ssls = 4 THEN 'Lieferschein gedruckt'
> >
> > WHEN t_ssls = 6 THEN 'Rechnung gedruckt'
> >
> > WHEN t_ssls = 7 THEN 'Auftrag abgeschlossen'
> >
> > ELSE 'Keine Statusinformationen verf?gbar'
> >
> > END
> > FROM inserted
> >
> >
> > exec [172.16.0.100].b2bdata.dbo.psetStatus_Vertr
> > @STATUS,
> > @AUFTRAGSNUMMER,
> > @AUFTRAGSPOSITION
> >
> >
> >
> >
> > COMMIT TRANSACTION
> >
> >
> >
> >
> >
> > The Code of the stored procedure:
> >
> > CREATE PROCEDURE psetStatus_Vertr
> > (
> > @STATUS as varchar (30),
> > @AUFTRAGSNUMMER as int,
> > @AUFTRAGSPOSITION as int
> > )
> >
> > AS
> >
> >
> > update STATUS set STATUS_VERTR = @STATUS
> > where AUFTRAGSNUMMER = @AUFTRAGSNUMMER and AUFTRAGSPOSITION =
> > @AUFTRAGSPOSITION
> > GO
> >
> >
> >
> > Any would be appreciated! Thanks in advance!
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >
> >

>
>
>

  Réponse avec citation
Vieux 01/09/2008, 14h20   #4
Uri Dimant
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: insert trigger calls stored proc

Lookup 'cursor' in the BOL



"krostpupe" <krostpupe@discussions.microsoft.com> wrote in message
news:B466D1D9-AD56-417C-AD7E-B086DF68F499@microsoft.com...
> Thank you for your fast reply!
>
> Unfortunatly i don´t know exactly what you mean! How can i loop through
> the
> inserted table?
>
> "Uri Dimant" wrote:
>
>> Hi
>> Yes ,as your trigger does not handle multi-inserted rows.
>> In you case you will have to loop thru the inserted table and send the
>> data
>>
>>
>> "krostpupe" <krostpupe@discussions.microsoft.com> wrote in message
>> news:A565A6F6-948C-4FE2-B0FB-1A558025104B@microsoft.com...
>> > Hello all!
>> >
>> > I have a insert trigger that should sent the responding column or
>> > columns
>> > to
>> > a stored procedure on another server. My guess is that only one row of
>> > data
>> > is transferred to the stored procedure. Of course i want all returning
>> > rows
>> > to be transferred!
>> > Trigger Code is:
>> >
>> > CREATE TRIGGER INS_045004 ON [dbo].[ttdsls045004]
>> > FOR INSERT
>> > AS
>> >
>> > set nocount on
>> >
>> > declare @Status as varchar(30)
>> > declare @Auftragsnummer as int
>> > declare @Auftragsposition as int
>> >
>> >
>> >
>> >
>> > BEGIN DISTRIBUTED TRANSACTION
>> >
>> >
>> > SELECT @Auftragsnummer = t_orno, @Auftragsposition = t_pono,
>> > @Status = CASE
>> >
>> > WHEN t_ssls = 1 THEN 'Auftragsbest?tigung gedruckt'
>> >
>> > WHEN t_ssls = 8 THEN 'Auftrag im Vertrieb'
>> >
>> > WHEN t_ssls = 3 THEN 'Auftrag am Lager'
>> >
>> > WHEN t_ssls = 4 THEN 'Lieferschein gedruckt'
>> >
>> > WHEN t_ssls = 6 THEN 'Rechnung gedruckt'
>> >
>> > WHEN t_ssls = 7 THEN 'Auftrag abgeschlossen'
>> >
>> > ELSE 'Keine Statusinformationen verf?gbar'
>> >
>> > END
>> > FROM inserted
>> >
>> >
>> > exec [172.16.0.100].b2bdata.dbo.psetStatus_Vertr
>> > @STATUS,
>> > @AUFTRAGSNUMMER,
>> > @AUFTRAGSPOSITION
>> >
>> >
>> >
>> >
>> > COMMIT TRANSACTION
>> >
>> >
>> >
>> >
>> >
>> > The Code of the stored procedure:
>> >
>> > CREATE PROCEDURE psetStatus_Vertr
>> > (
>> > @STATUS as varchar (30),
>> > @AUFTRAGSNUMMER as int,
>> > @AUFTRAGSPOSITION as int
>> > )
>> >
>> > AS
>> >
>> >
>> > update STATUS set STATUS_VERTR = @STATUS
>> > where AUFTRAGSNUMMER = @AUFTRAGSNUMMER and AUFTRAGSPOSITION =
>> > @AUFTRAGSPOSITION
>> > GO
>> >
>> >
>> >
>> > Any would be appreciated! Thanks in advance!
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >
>> >

>>
>>
>>



  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 07h36.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13238 seconds with 12 queries