TR_CONSTITUENT_INSERT_SEARCHCONSTITUENT

Definition

Copy


        CREATE trigger TR_CONSTITUENT_INSERT_SEARCHCONSTITUENT on dbo.CONSTITUENT after insert not for replication
        as begin
          if isnull(context_info(),0x)<>0xE2DF375A033A104382689B8EAC5165AD
          begin
            if exists (select 1 from sys.TABLES where TYPE = 'U' and NAME = 'SEARCHCONSTITUENT')
            begin
              -- add name-only rows to searchconstituent, these will be removed once addresses are added

              insert into dbo.SEARCHCONSTITUENT (ID,CONSTITUENTID,
                                                  KEYNAME,FIRSTNAME,MIDDLENAME,NAMETYPECODE,
                                                  TITLECODEID,SUFFIXCODEID,
                                                  ISORGANIZATION,ISGROUP)
              select newid(),
                      inserted.ID,
                      c.KEYNAME,
                      c.FIRSTNAME,
                      c.MIDDLENAME,
                      c.NAMETYPECODE,
                      c.TITLECODEID,
                      c.SUFFIXCODEID,
                      c.ISORGANIZATION,
                      c.ISGROUP
              from inserted
              inner join dbo.V_CONSTITUENTALLNAMES c on c.ID = inserted.ID
              where c.KEYNAME<>''
            end
          end
        end