cancel
Showing results for 
Search instead for 
Did you mean: 

Creating Function on HANA

rodney_rivera22
Explorer
0 Kudos

Hi,

I'm struggling to get a SQL function to HANA by HANA Studio. This is the code that I'm using:

CREATE FUNCTION "MBCF"."CUSTOM_PRODUCTION_ISSUED" (IN DENTRY nvarchar(20), IN ITEM varchar(20))

RETURNS AVG_PRICE DECIMAL(15, 6)

LANGUAGE SQLSCRIPT

AS

BEGIN

SELECT (SELECT ISNULL(AVG(ISNULL("Price", 0)), 0) FROM IGE1 WHERE "BaseRef" = :DENTRY AND "ItemCode" = :ITEM) INTO AVG_PRICE FROM DUMMY;

END;

But, the following error is presented when executing:

inconsistent datatype: DECIMAL or INT are invalid function argument types: line 7 col 24 (at pos 196)

Any help?

Thanks

Accepted Solutions (1)

Accepted Solutions (1)

rodney_rivera22
Explorer
0 Kudos

Hi,

I did change the ISNULL with a COALESCE and it worked.

Thanks,

Answers (1)

Answers (1)

0 Kudos

You need to use IFNULL instead of ISNULL, IFNULL is the equivalent SQL function for HANA