Hi Experts!
I am trying to get experience with Stored Procedures using Input and Output Parameters.
I am trying to design a simple SP for the current date, that takes an Input Parameter ("IP_FORMAT") as 'Year','Month',or 'Date' and returns the correct format.
I can't seem to get the syntax correct. I have tried both an IF-THEN and CASE statement.
Please advise me where I am going wrong. Thank you.
CREATE PROCEDURE <SCHEMA>.SP_Date
(IN IP_FORMAT VARCHAR (5), OUT V_OUT NVARCHAR (8))
LANGUAGE SQLSCRIPT AS
BEGIN
DECLARE V_DATE NVARCHAR (8);
SELECT TO_NVARCHAR((current_date),'YYYYMMDD') AS V_DATE From dummy;
IF :IP_FORMAT like 'Year'
THEN
select left(V_DATE,4) AS V_OUT from dummy
ELSE
select V_Date AS V_OUT from dummy
END IF;
END;