0

I have created a user-defined function using this sqlscript.

CREATE FUNCTION ZYESTERDAY ()
RETURNS YESTERDAY VARCHAR(8)
LANGUAGE SQLSCRIPT AS 
BEGIN
    SELECT TO_DATS(ADD_DAYS(CURRENT_DATE, -1)) INTO YESTERDAY
    FROM DUMMY;
END;

Although it worked fine but I got this warning message java.sql.SQLWarning: Not recommended feature: Using SELECT INTO in Scalar UDF.
I wonder which syntax I should use to avoid the warning message?
I tried to use YESTERDAY := SELECT TO_DATS(ADD_DAYS(CURRENT_DATE, -1)) FROM DUMMY;but an error message poped up like syntax error near select.

Sandra Rossi
  • 11,934
  • 5
  • 22
  • 48
Lisen
  • 168
  • 1
  • 2
  • 11
  • Please do not SHOUT when posting. Text in ALL CAPS is more difficult to read and understand, and won't get you help any faster. It's also rather impolite to SHOUT at people you're asking for **free help** to solve **your problem**. – Ken White Oct 19 '22 at 01:10

1 Answers1

1

For your specific example this syntax seems much more straight-forward:

CREATE OR REPLACE FUNCTION ZYESTERDAY ()
RETURNS YESTERDAY VARCHAR(8)
LANGUAGE SQLSCRIPT AS 
BEGIN
    YESTERDAY = TO_DATS(ADD_DAYS(CURRENT_DATE, -1));
END;

This SAP Community Answer suggests that performance implications may be the reason for the warning. On my current SAP HANA Cloud system, I am not receiving this warning when creating the UDF using your syntax.

Mathias Kemeter
  • 933
  • 2
  • 11