all groups > sql server data warehouse > december 2005 >
You're in the

sql server data warehouse

group:

Trigger...???


Trigger...??? Richard Oliveira Bento
12/13/2005 9:27:31 PM
sql server data warehouse:
Alguem sabe como referenciar uma determinada coluna?=20

Exemplo:

/* Variavel @xCOD */

Re: Trigger...??? Richard Oliveira Bento
12/14/2005 10:09:53 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 =3D column



MC
[quoted text, click to view]
Alguem sabe como referenciar uma determinada coluna?=20

Exemplo:

/* Variavel @xCOD */

Re: Trigger...??? MC
12/14/2005 1:14:55 PM
Ugh, dont know the language, but based on the code, perhaps

SELECT @xCOD =3D column



MC
[quoted text, click to view]
Alguem sabe como referenciar uma determinada coluna?=20

Exemplo:

/* Variavel @xCOD */

Re: Trigger...??? Richard Oliveira Bento
12/14/2005 1:31:18 PM
OK! My problem is the Code...

- - - - - - - -=20

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

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

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

/* Se N=E3o existe Registro Inclui Para Tabela de Calculos */
IF @@ROWCOUNT =3D 0
BEGIN
/* Insere novo Registro */
INSERT into dbo.tbcc002 ( cod_usr, nome_campanha, total_base, =
total_naotrab, em_negociacao,=20
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 =20
END=20
GO



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



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
[quoted text, click to view]
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 =3D column



MC
[quoted text, click to view]
Alguem sabe como referenciar uma determinada coluna?=20

Exemplo:

/* Variavel @xCOD */

SET @xCOD =3D nome da coluna <<--- Coluna =E0 ser =
Re: Trigger...??? MC
12/14/2005 1:43:31 PM
Umm, if the code I posted isnt helping, can you post what is the =
problem?

MC
[quoted text, click to view]
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 =3D column



MC
[quoted text, click to view]
Alguem sabe como referenciar uma determinada coluna?=20

Exemplo:

/* Variavel @xCOD */

SET @xCOD =3D nome da coluna <<--- Coluna =E0 ser =
Re: Trigger...??? MC
12/15/2005 8:27:40 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
[quoted text, click to view]
OK! My problem is the Code...

- - - - - - - -=20

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

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

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

/* Se N=E3o existe Registro Inclui Para Tabela de Calculos */
IF @@ROWCOUNT =3D 0
BEGIN
/* Insere novo Registro */
INSERT into dbo.tbcc002 ( cod_usr, nome_campanha, total_base, =
total_naotrab, em_negociacao,=20
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 =20
END=20
GO



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



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
[quoted text, click to view]
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 =3D column



MC
[quoted text, click to view]
Alguem sabe como referenciar uma determinada coluna?=20

Exemplo:

/* Variavel @xCOD */

SET @xCOD =3D nome da coluna <<--- Coluna =E0 ser =
AddThis Social Bookmark Button