Hi,
I am trying to convert a function which was in SQL to HANA, here the function
CREATE FUNCTION "PAYROLLDBTEST".GetEmployeeWorkingDays
(
-- Add the parameters for the function here
EmpID int,
Date datetime
)
RETURNS TABLE("WorkingDaysInMonth" float)
LANGUAGE SQLSCRIPT
SQL SECURITY INVOKER
AS
BEGIN
-- Declare the return variable here
DECLARE WorkingDaysInMonth float;
DECLARE EmploymentType nvarchar(50);
DECLARE CalculationType int;
-- Add the T-SQL statements to compute the return value here
SELECT "U_EmpTypeID" AS "EmploymentType" FROM OHEM WHERE "empID" = :EmpID;
SELECT "U_CalculationType" AS "CalculationType" FROM "@EMPLOYMENT_TYPES" WHERE "Code" = :EmploymentType;
if (:CalculationType = 1) -- As per calendar
THEN
WorkingDaysInMonth := DATE("PAYROLLDBTEST".B1CFLMonthEnd(:Date));
END IF;
if (:CalculationType = 2) -- Custom days
THEN
SELECT "U_CustomDays" AS "WorkingDaysInMonth" FROM "@EMPLOYMENT_TYPES" WHERE "Code" = :EmploymentType;
END IF;
if (:WorkingDaysInMonth = 0 OR :WorkingDaysInMonth is null)
THEN
WorkingDaysInMonth := DAY(dbo.B1CFLMonthEnd(:Date));
END IF;
-- Return the result of the function
RETURN WorkingDaysInMonth;
END;
Giving error "invalid name of function or procedure: DATE"
Could you please tell whats wrong.
Thanks