Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Functions and stored Procedure not working

$
0
0

This is the Script

USE [RLC_University]
GO
/****** Object:  UserDefinedFunction [dbo].[fn_GetIsRequired]    Script Date: 5/14/2014 5:37:08 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

 


-- =========================================================== 
-- Object Name: fn_GetIsRequired
-- 
-- Object Type: User Function 
-- 
-- Description: This function returns a BIT that specifies if a section is required or not
--
-- Return values: Returns error messages 
--  
-- Revision History: 
-- Date        Developer     Comments 
-- ---------- ------------  -------------------------------
-- 05/08/2012  O.Adeleye      Created 
-- ===========================================================
ALTER FUNCTION [dbo].[fn_GetIsRequired]
(
 -- Add the parameters for the function here
 @IsRequired BIT,
 @EffectiveDate DATETIME,
 @HireDate DATETIME,
 @AssignmentDate DATETIME,
 @SectionActivityID INT
)
RETURNS BIT
AS
BEGIN
 -- Declare the return variable here
 DECLARE @CalculatedIsRequired as BIT
 SET @CalculatedIsRequired = @IsRequired
 
 --if this quiz is effective from hire date
 IF(@SectionActivityID = 2)
  BEGIN
   IF(@EffectiveDate > @HireDate)
    BEGIN
     SET @CalculatedIsRequired = 0
    END
  END
 
 --if this quiz is effective from assignment date
 IF(@SectionActivityID = 3)
  BEGIN
   IF(@EffectiveDate > @AssignmentDate)
    BEGIN
     SET @CalculatedIsRequired = 0
    END
  END
  
 -- Return the result of the function
 RETURN @CalculatedIsRequired;
END



Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>