
/***********
		Trigger für die Datenbank FKL der mobilen Datenerfassung
		wie das Skript für die Hauptdatenbank
		
		2024-03-30 erstellt

	*********************************************************************************************/

use FKL
go


declare @tName varchar(255)

declare tCur scroll cursor for select name from sysobjects where OBJECTPROPERTY(id, N'IsTrigger') = 1
open tCur
fetch first from tCur into @tName
while (@@fetch_status <> -1) begin
  exec ('drop trigger ' + @tName)
  fetch next from tCur into @tName
end
close tCur
deallocate tCur
go


CREATE trigger tD_gemeinde on gemeinde
  for DELETE
  as
begin set nocount on

  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insgemID int,
           @errno   int,
           @errmsg  varchar(max)

  select @numrows = @@rowcount

    if exists (
      select * from deleted,probestelle
      where
        probestelle.psGemeinde = deleted.gemID
    )
    begin
      select @errno  = 50001,
             @errmsg = 'Die Gemeinde kann nicht gelöscht werden, weil sie mindestens einer Probestelle zugeordnet ist.'
      goto error
    end

  return
error:
    select @errmsg = @errmsg + ' [nr=' + cast(@errno as varchar) + ';server=' + @@SERVERNAME + ']'; raiserror (@errmsg, 16, 1);
    rollback transaction
end
go


/****** Objekt:  Trigger dbo.TD_einrichtung    Skriptdatum: 14.12.2000 00:35:28 ******/
create trigger TD_einrichtung on einrichtung
  for DELETE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* DELETE trigger on einrichtung */
/* default body for TD_einrichtung */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inserID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount

/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
    /* einrichtung R/36 probestelle ON PARENT DELETE RESTRICT */
    if exists (
      select * from deleted,probestelle
      where
        /*  %JoinFKPK(probestelle,deleted," = "," and") */
        probestelle.psEinrichtung_B = deleted.erID
    )
    begin
      select @errno  = 50001,
             @errmsg = 'Die Einrichtung kann nicht gelöscht werden, weil sie mindestens einer Probestelle zugeordnet ist.'
      goto error
    end

/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
    /* einrichtung R/35 probestelle ON PARENT DELETE RESTRICT */
    if exists (
      select * from deleted,probestelle
      where
        /*  %JoinFKPK(probestelle,deleted," = "," and") */
        probestelle.psEinrichtung_F = deleted.erID
    )
    begin
      select @errno  = 50001,
             @errmsg = 'Die Einrichtung kann nicht gelöscht werden, weil sie mindestens einer Probestelle zugeordnet ist.'
      goto error
    end


  return
error:
    select @errmsg = @errmsg + ' [nr=' + cast(@errno as varchar) + ';server=' + @@SERVERNAME + ']'; raiserror (@errmsg, 16, 1);
    rollback transaction
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TI_einrichtung    Skriptdatum: 14.12.2000 00:35:28 ******/
create trigger TI_einrichtung on einrichtung
  for INSERT
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* INSERT trigger on einrichtung */
/* default body for TI_einrichtung */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inserID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



/* nur fuer INSERT einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  erID from inserted
  update einrichtung set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where erID = @ID

  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TU_einrichtung    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TU_einrichtung on einrichtung
  for UPDATE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* UPDATE trigger on einrichtung */
/* default body for TU_einrichtung */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inserID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount


 
 /* nur fuer UPDATE einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  erID from inserted
  update einrichtung set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where erID = @ID

  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TI_fangprot    Skriptdatum: 14.12.2000 00:35:28 ******/
create trigger TI_fangprot on fangprot
  for INSERT
  as
/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
/* INSERT trigger on fangprot */
/* default body for TI_fangprot */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insfpID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



 /* nur fuer INSERT einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  fpID from inserted
  update fangprot set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where fpID = @ID

  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TU_fangprot    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TU_fangprot on fangprot
  for UPDATE
  as
/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
/* UPDATE trigger on fangprot */
/* default body for TU_fangprot */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insfpID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



 /* nur fuer UPDATE einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  fpID from inserted
  update fangprot set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where fpID = @ID

  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TI_fangprot_wiss    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TI_fangprot_wiss on fangprot_wiss
  for INSERT
  as
/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
/* INSERT trigger on fangprot_wiss */
/* default body for TI_fangprot_wiss */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insfpwID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



 /* nur fuer INSERT einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  fpwID from inserted
  update fangprot_wiss set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where fpwID = @ID

return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TU_fangprot_wiss    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TU_fangprot_wiss on fangprot_wiss
  for UPDATE
  as
/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
/* UPDATE trigger on fangprot_wiss */
/* default body for TU_fangprot_wiss */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insfpwID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



 /* nur fuer UPDATE einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  fpwID from inserted
  update fangprot_wiss set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where fpwID = @ID

  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TD_fischart    Skriptdatum: 14.12.2000 00:35:28 ******/
create trigger TD_fischart on fischart
  for DELETE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* DELETE trigger on fischart */
/* default body for TD_fischart */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insfID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount

/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
    /* fischart R/28 fangprot_wiss ON PARENT DELETE RESTRICT */
    if exists (

      select * from deleted,fangprot_wiss
      where
        /*  %JoinFKPK(fangprot_wiss,deleted," = "," and") */
        fangprot_wiss.fpwFischart = deleted.fID
    )
    begin
      select @errno  = 50001,
             @errmsg = 'Die Fischart kann nicht gelöscht werden, weil sie in mindestens einem Fangprotokoll verwendet wird.'
      goto error
    end

/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
    /* fischart R/26 fangprot ON PARENT DELETE RESTRICT */
    if exists (
      select * from deleted,fangprot
      where
        /*  %JoinFKPK(fangprot,deleted," = "," and") */
        fangprot.fpFischart = deleted.fID
    )
    begin
      select @errno  = 50001,
             @errmsg = 'Die Fischart kann nicht gelöscht werden, weil sie in mindestens einem Fangprotokoll verwendet wird.'
      goto error
    end


  return
error:
    select @errmsg = @errmsg + ' [nr=' + cast(@errno as varchar) + ';server=' + @@SERVERNAME + ']'; raiserror (@errmsg, 16, 1);
    rollback transaction
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TI_fischart    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TI_fischart on fischart
  for INSERT
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* INSERT trigger on fischart */
/* default body for TI_fischart */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insfID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
 

 /* nur fuer INSERT einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  fID from inserted
  update fischart set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where fID = @ID

  return

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TU_fischart    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TU_fischart on fischart
  for UPDATE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* UPDATE trigger on fischart */
/* default body for TU_fischart */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insfID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount

 
 /* nur fuer UPDATE einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  fID from inserted
  update fischart set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where fID = @ID

  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TD_gewaessertyp    Skriptdatum: 14.12.2000 00:35:28 ******/
create trigger TD_gewaessertyp on gebiets_kz
  for DELETE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* DELETE trigger on gebiets_kz */
/* default body for TD_gewaessertyp */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insgID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount

/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
    /* gebiets_kz R/23 probestelle ON PARENT DELETE RESTRICT */
    if exists (
      select * from deleted,probestelle
      where
        /*  %JoinFKPK(probestelle,deleted," = "," and") */
        probestelle.psGebiets_kz = deleted.gID
    )
    begin
      select @errno  = 50001,
             @errmsg = 'Dieses Gewässer kann nicht gelöscht werden, weil es mindestens einer Probestelle zugeordnet ist.'
      goto error
    end


  return
error:
    select @errmsg = @errmsg + ' [nr=' + cast(@errno as varchar) + ';server=' + @@SERVERNAME + ']'; raiserror (@errmsg, 16, 1);
    rollback transaction
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TI_gewaessertyp    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TI_gewaessertyp on gebiets_kz
  for INSERT
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* INSERT trigger on gebiets_kz */
/* default body for TI_gewaessertyp */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insgID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
 
 /* nur fuer INSERT einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  gID from inserted
  update gebiets_kz set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where gID = @ID

  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TU_gewaessertyp    Skriptdatum: 14.12.2000 00:35:30 ******/
create trigger TU_gewaessertyp on gebiets_kz
  for UPDATE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* UPDATE trigger on gebiets_kz */
/* default body for TU_gewaessertyp */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @insgID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  
 /* nur fuer UPDATE einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  gID from inserted
  update gebiets_kz set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where gID = @ID


  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TD_katalog    Skriptdatum: 14.12.2000 00:35:28 ******/
CREATE trigger TD_katalog on katalog
  for DELETE
  as
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inskID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount
  select @errmsg = 'Dieser Katalogeintrag kann nicht gelöscht werden, weil er bei mindestens einer Probestelle verwendet wurde.'
  select @errno = 50001

    if exists (
      select * from deleted,k2ps_msel
      where
        k2ps_msel.k2ps_mselKatalog = deleted.kID
    )
    goto error

    if exists (
      select * from deleted,probestelle
      where
        psBetreff = deleted.kID
    )
    goto error

    if exists (
      select * from deleted,probestelle
      where
        psErfass_Kat = deleted.kID
    )
    goto error

    if exists (
      select * from deleted,probestelle
      where
        psFischreg = deleted.kID
    )
    goto error

  return
error:
    select @errmsg = @errmsg + ' [nr=' + cast(@errno as varchar) + ';server=' + @@SERVERNAME + ']'; raiserror (@errmsg, 16, 1);
    rollback transaction
end


GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TI_katalog    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TI_katalog on katalog
  for INSERT
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* INSERT trigger on katalog */
/* default body for TI_katalog */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inskID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



 /* nur fuer INSERT einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  kID from inserted
  update katalog set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where kID = @ID

  return

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TU_katalog    Skriptdatum: 14.12.2000 00:35:30 ******/
create trigger TU_katalog on katalog
  for UPDATE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* UPDATE trigger on katalog */
/* default body for TU_katalog */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inskID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



 /* nur fuer UPDATE einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  kID from inserted
  update katalog set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where kID = @ID

  return

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TD_probestelle    Skriptdatum: 14.12.2000 00:35:28 ******/
create trigger TD_probestelle on probestelle
  for DELETE
  as
/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
/* DELETE trigger on probestelle */
/* default body for TD_probestelle */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @inspsID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount

/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
    /* probestelle R/42 k2ps_msel ON PARENT DELETE CASCADE */
    delete k2ps_msel
      from k2ps_msel,deleted
      where
        /*  %JoinFKPK(k2ps_msel,deleted," = "," and") */
        k2ps_msel.k2ps_mselProbestelle = deleted.psID

/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
    /* probestelle R/34 fangprot_wiss ON PARENT DELETE CASCADE */
    delete fangprot_wiss
      from fangprot_wiss,deleted
      where
        /*  %JoinFKPK(fangprot_wiss,deleted," = "," and") */
        fangprot_wiss.fpwProbestelle = deleted.psID

/* ERwin Builtin Fri Feb 11 17:59:15 2000 */
    /* probestelle R/27 fangprot ON PARENT DELETE CASCADE */
    delete fangprot
      from fangprot,deleted
      where
        /*  %JoinFKPK(fangprot,deleted," = "," and") */
        fangprot.fpProbestelle = deleted.psID


  return
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO




/****** Objekt:  Trigger dbo.TD_tknr_name    Skriptdatum: 14.12.2000 00:35:28 ******/
create trigger TD_tknr_name on tknr_name
  for DELETE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* DELETE trigger on tknr_name */
/* default body for TD_tknr_name */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @instkID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount

/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
    /* tknr_name R/47 probestelle ON PARENT DELETE RESTRICT */
    if exists (
      select * from deleted,probestelle
      where
        /*  %JoinFKPK(probestelle,deleted," = "," and") */
        probestelle.psTKnr_name = deleted.tkID
    )
    begin
      select @errno  = 50001,
             @errmsg = 'Diese topografische Karte kann nicht gelöscht werden, weil sie mindestens einer Probestelle zugeordnet wurde.'
      goto error
    end


  return
error:
    select @errmsg = @errmsg + ' [nr=' + cast(@errno as varchar) + ';server=' + @@SERVERNAME + ']'; raiserror (@errmsg, 16, 1);
    rollback transaction
end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TI_tknr_name    Skriptdatum: 14.12.2000 00:35:29 ******/
create trigger TI_tknr_name on tknr_name
  for INSERT
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* INSERT trigger on tknr_name */
/* default body for TI_tknr_name */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @instkID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount



 /* nur fuer INSERT einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  tkID from inserted
  update tknr_name set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where tkID = @ID

  return

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO


/****** Objekt:  Trigger dbo.TU_tknr_name    Skriptdatum: 14.12.2000 00:35:30 ******/
create trigger TU_tknr_name on tknr_name
  for UPDATE
  as
/* ERwin Builtin Fri Feb 11 17:59:16 2000 */
/* UPDATE trigger on tknr_name */
/* default body for TU_tknr_name */
begin   set nocount on
  declare  @numrows int,
           @nullcnt int,
           @validcnt int,
           @instkID int,
           @errno   int,
           @errmsg  varchar(255)

  select @numrows = @@rowcount




 /* nur fuer UPDATE einzelner Datensaetze: */
  if (@numrows > 1) return
  declare @ID int
  select @ID =  tkID from inserted
  update tknr_name set UPD_USER = SUSER_SNAME(), UPD_TIME = getdate()
  where tkID = @ID

  return

end
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

