spAddUpdate_NetworkRanking

Parameters

Parameter Parameter Type Mode Description
@PKID int INOUT
@Name nvarchar(100) IN
@Description nvarchar(255) IN
@RankingType int IN
@LowerBound int IN
@UpperBound int IN
@SiteContentID int IN

Definition

Copy



  CREATE  PROCEDURE [dbo].[spAddUpdate_NetworkRanking]
  (
  @PKID int output,
  @Name nvarchar(100),
  @Description nvarchar(255),
  @RankingType int,
  @LowerBound int,
  @UpperBound int,
  @SiteContentID int
  )
  AS
  BEGIN

  --Validate this Ranking first

  DECLARE @Count int

  SELECT @Count = Count(*) FROM NetworkRanking
  WHERE
  (LowerBound BETWEEN @LowerBound AND @UpperBound
  OR
  UpperBound BETWEEN @LowerBound AND @UpperBound)
  AND
  RankingType = @RankingType
  AND
  SiteContentID = @SiteContentID
  AND
  ID <> @PKID

  if @Count > 0
  RAISERROR('Ranking bounds overlap existing records.',16,1)
  else

  IF (@PKID<=0)
    BEGIN
    INSERT INTO NetworkRanking
    (
    Name, Description, RankingType, LowerBound, UpperBound, SiteContentID
    )
    VALUES
    (
    @Name, @Description, @RankingType, @LowerBound, @UpperBound, @SiteContentID
    )
    SELECT @PKID = @@Identity
    END
    ELSE
    UPDATE NetworkRanking SET
    Name = @Name,
    Description = @Description,
    RankingType    = @RankingType,
    LowerBound = @LowerBound,
    UpperBound = @UpperBound,
    SiteContentID = @SiteContentID
    WHERE [ID]=@PKID
    END