Unix Technical Forum

Trigger...???

This is a discussion on Trigger...??? within the SQL Server Data Warehousing forums, part of the Microsoft SQL Server category; --> Alguem sabe como referenciar uma determinada coluna? Exemplo: /* Variavel @xCOD */ SET @xCOD = nome da coluna <<--- ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server Data Warehousing

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 07:43 PM
Richard Oliveira Bento
 
Posts: n/a
Default Trigger...???

Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/* Variavel @xCOD */

SET @xCOD = nome da coluna <<--- Coluna à ser referenciada
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 07:43 PM
MC
 
Posts: n/a
Default Re: Trigger...???

Ugh, dont know the language, but based on the code, perhaps

SELECT @xCOD = column



MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:%239ANUzDAGHA.2148@TK2MSFTNGP10.phx.gbl...
Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/* Variavel @xCOD */

SET @xCOD = nome da coluna <<--- Coluna à ser referenciada
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 07:43 PM
Richard Oliveira Bento
 
Posts: n/a
Default Re: Trigger...???

SQL SERVER 2000


"MC" <marko_culo#@#yahoo#.#com#> escreveu na mensagem news:%23yrM5ZKAGHA.2708@TK2MSFTNGP12.phx.gbl...
Ugh, dont know the language, but based on the code, perhaps

SELECT @xCOD = column



MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:%239ANUzDAGHA.2148@TK2MSFTNGP10.phx.gbl...
Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/* Variavel @xCOD */

SET @xCOD = nome da coluna <<--- Coluna à ser referenciada
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 07:43 PM
MC
 
Posts: n/a
Default Re: Trigger...???

Umm, if the code I posted isnt helping, can you post what is the problem?

MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:uNXDadKAGHA.1028@TK2MSFTNGP11.phx.gbl...
SQL SERVER 2000


"MC" <marko_culo#@#yahoo#.#com#> escreveu na mensagem news:%23yrM5ZKAGHA.2708@TK2MSFTNGP12.phx.gbl...
Ugh, dont know the language, but based on the code, perhaps

SELECT @xCOD = column



MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:%239ANUzDAGHA.2148@TK2MSFTNGP10.phx.gbl...
Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/* Variavel @xCOD */

SET @xCOD = nome da coluna <<--- Coluna à ser referenciada
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 02-27-2008, 07:43 PM
Richard Oliveira Bento
 
Posts: n/a
Default Re: Trigger...???

OK! My problem is the Code...

- - - - - - - -

SET NOCOUNT ON
GO
CREATE TRIGGER [TgSAV001_ConditionalInsert] ON [tbcc003]
FOR INSERT
AS
Declare
@xCOD varchar(10), @xNOME varchar(30), @xDTAIMP datetime, @xDTAFINAL datetime

SET @xCOD = NEW.cod_usr()
SET @XNOME = NEW.nome_campanha()
SET @xDTAIMP = NEW.data_importacao()
SET @xDTAFINAL = NEW.data_finalizacao()

Begin
SET NOCOUNT OFF
/* Pesquisa Registro se Existe na Tabela de Calculos */
SELECT nome_campanha FROM tbcc002 a
WHERE a.cod_usr = @xCOD
AND a.nome_campanha = @xNOME

/* Se Não existe Registro Inclui Para Tabela de Calculos */
IF @@ROWCOUNT = 0
BEGIN
/* Insere novo Registro */
INSERT into dbo.tbcc002 ( cod_usr, nome_campanha, total_base, total_naotrab, em_negociacao,
total_naoafiliado, total_afiliado, total_jaafiliado, total_telerrado, total_telocupado,
total_telnatende, total_foratarget, total_finalizado,total_agendamento, data_import,
data_finalizacao )
Values ( @xCOD, @xNOME, 0,0,0,0,0,0,0,0,0,0,0,0, @xDTAIMP, @xDTAFINAL )
END
END
GO



/* --- ERROR ao Incluir Registro: --- */
/* Invalid object name 'NEW.cod_usr'. */



Como fosso pra identificar uma coluna da tabela que executo a Trigger?


Obrigado









"MC" <marko_culo#@#yahoo#.#com#> escreveu na mensagem news:eTjo3pKAGHA.2812@TK2MSFTNGP09.phx.gbl...
Umm, if the code I posted isnt helping, can you post what is the problem?

MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:uNXDadKAGHA.1028@TK2MSFTNGP11.phx.gbl...
SQL SERVER 2000


"MC" <marko_culo#@#yahoo#.#com#> escreveu na mensagem news:%23yrM5ZKAGHA.2708@TK2MSFTNGP12.phx.gbl...
Ugh, dont know the language, but based on the code, perhaps

SELECT @xCOD = column



MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:%239ANUzDAGHA.2148@TK2MSFTNGP10.phx.gbl...
Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/* Variavel @xCOD */

SET @xCOD = nome da coluna <<--- Coluna à ser referenciada
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 02-27-2008, 07:43 PM
MC
 
Posts: n/a
Default Re: Trigger...???

It works for me. Hmm,are you certain you have a function cod_usr() with owner NEW ? Or, in case of 2005 is it in schema NEW?

MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:ODQH4NMAGHA.980@tk2msftngp13.phx.gbl...
OK! My problem is the Code...

- - - - - - - -

SET NOCOUNT ON
GO
CREATE TRIGGER [TgSAV001_ConditionalInsert] ON [tbcc003]
FOR INSERT
AS
Declare
@xCOD varchar(10), @xNOME varchar(30), @xDTAIMP datetime, @xDTAFINAL datetime

SET @xCOD = NEW.cod_usr()
SET @XNOME = NEW.nome_campanha()
SET @xDTAIMP = NEW.data_importacao()
SET @xDTAFINAL = NEW.data_finalizacao()

Begin
SET NOCOUNT OFF
/* Pesquisa Registro se Existe na Tabela de Calculos */
SELECT nome_campanha FROM tbcc002 a
WHERE a.cod_usr = @xCOD
AND a.nome_campanha = @xNOME

/* Se Não existe Registro Inclui Para Tabela de Calculos */
IF @@ROWCOUNT = 0
BEGIN
/* Insere novo Registro */
INSERT into dbo.tbcc002 ( cod_usr, nome_campanha, total_base, total_naotrab, em_negociacao,
total_naoafiliado, total_afiliado, total_jaafiliado, total_telerrado, total_telocupado,
total_telnatende, total_foratarget, total_finalizado,total_agendamento, data_import,
data_finalizacao )
Values ( @xCOD, @xNOME, 0,0,0,0,0,0,0,0,0,0,0,0, @xDTAIMP, @xDTAFINAL )
END
END
GO



/* --- ERROR ao Incluir Registro: --- */
/* Invalid object name 'NEW.cod_usr'. */



Como fosso pra identificar uma coluna da tabela que executo a Trigger?


Obrigado









"MC" <marko_culo#@#yahoo#.#com#> escreveu na mensagem news:eTjo3pKAGHA.2812@TK2MSFTNGP09.phx.gbl...
Umm, if the code I posted isnt helping, can you post what is the problem?

MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:uNXDadKAGHA.1028@TK2MSFTNGP11.phx.gbl...
SQL SERVER 2000


"MC" <marko_culo#@#yahoo#.#com#> escreveu na mensagem news:%23yrM5ZKAGHA.2708@TK2MSFTNGP12.phx.gbl...
Ugh, dont know the language, but based on the code, perhaps

SELECT @xCOD = column



MC
"Richard Oliveira Bento" <eu@microsoft.com> wrote in message news:%239ANUzDAGHA.2148@TK2MSFTNGP10.phx.gbl...
Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/* Variavel @xCOD */

SET @xCOD = nome da coluna <<--- Coluna à ser referenciada
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:29 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com