Home > Archive > MS SQL Data Warehousing > December 2005 > Trigger...???









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Trigger...???
Richard Oliveira Bento

2005-12-13, 8:23 pm

Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/* Variavel @xCOD */

SET @xCOD = nome da coluna <<--- Coluna à ser referenciada
MC

2005-12-14, 7:23 am

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
Richard Oliveira Bento

2005-12-14, 7:23 am

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
MC

2005-12-14, 7:23 am

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
Richard Oliveira Bento

2005-12-14, 11:23 am

OK! My problem is the Code...

- - - - - - - -

SET NOCOUNT ON
GO
CREATE TRIGGER & #91;TgSAV001_Conditi
onalInsert] 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,tot
al_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
MC

2005-12-15, 3:23 am

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 & #91;TgSAV001_Conditi
onalInsert] 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,tot
al_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
Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2009 droptable.com