﻿DROP PROCEDURE IF EXISTS uspUpdateTanitasiOraOrarendiOraGroupIds
GO

CREATE PROCEDURE uspUpdateTanitasiOraOrarendiOraGroupIds
    @pDatumtol datetime
   ,@pDatumig datetime
   ,@pOrarendiOraId int
   ,@pModifier int
AS BEGIN
    SET NOCOUNT ON;

    UPDATE T_TANITASIORA
    SET C_ORARENDIORAGROUPID = NULL 
       ,C_ORARENDIORAID = NULL
       ,LASTCHANGED = GETDATE()
       ,SERIAL += 1
       ,MODIFIER = @pModifier
    WHERE (C_ORARENDIORAGROUPID = @pOrarendiOraId OR C_ORARENDIORAID = @pOrarendiOraId)
      AND C_DATUM >= @pDatumtol
      AND (C_DATUM <= @pDatumig OR (@pDatumig IS NULL AND C_DATUM = @pDatumtol))


END
GO
