Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
DB Engine
SQL ServerMSDESQL Server CE
Services
Analysis (Data Mining)Analysis (OLAP)DTSIntegration ServicesNotification ServicesReporting Services
Programming
CLRConnectivitySQLXML
Other Technologies
ClusteringEnglish QueryFull-Text SearchReplicationService Broker
General
Data WarehousingPerformanceSecuritySetupSQL Server ToolsOther SQL Server Topics
DirectoryUser Groups
Related Topics
MS AccessOther DB ProductsMS Server Products.NET DevelopmentVB DevelopmentJava DevelopmentMore Topics ...

SQL Server Forum / General / Data Warehousing / December 2005

Tip: Looking for answers? Try searching our database.

Trigger...???

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard Oliveira Bento - 13 Dec 2005 23:27 GMT
Alguem sabe como referenciar uma determinada coluna?

Exemplo:

/*    Variavel @xCOD     */

 SET @xCOD = nome da coluna    <<---  Coluna à ser referenciada
MC - 14 Dec 2005 12:12 GMT
Ugh, dont know the language, but based on the code, perhaps

SELECT @xCOD = column

MC
 Alguem sabe como referenciar uma determinada coluna?

 Exemplo:

 /*    Variavel @xCOD     */

   SET @xCOD = nome da coluna    <<---  Coluna à ser referenciada
Richard Oliveira Bento - 14 Dec 2005 12:09 GMT
SQL SERVER 2000

 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 - 14 Dec 2005 12:37 GMT
Umm, if the code I posted isnt helping, can you post what is the problem?

MC
 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 - 14 Dec 2005 15:31 GMT
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

 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 - 15 Dec 2005 07:21 GMT
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
 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
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.