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 <<--- ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| |||
| 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 |
| ||||
| 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 |