Quantcast
Channel: SCN : Discussion List - SAP HANA Developer Center
Viewing all articles
Browse latest Browse all 6412

Stored Procedure Example

$
0
0

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;


Viewing all articles
Browse latest Browse all 6412

Trending Articles