cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

SAP SQL Script(Table Function) Script error

praveen_kumar334
Participant
0 Likes
703

Hi Team,

While creating SQL View with SQLScript(Table Function), I am getting the below error. Could someone please help me in fixing this error.

Accepted Solutions (0)

Answers (2)

Answers (2)

XaviPolo
Active Contributor

DSP already includes automatically some parts of the function that you don't have to write in the SQL Script, such as the definition of the table it returns, the parameters or the BEGIN/END that encompasses the whole function.

Apart from that, it is already a normal function, you can put the variable DECLARES at the top, use conditionals, etc.

Something that in HANA is:

FUNCTION "XP"."TF_SAMPLE_SUM" ( IP_A INT, IP_B INT) 
  RETURNS TABLE
    (
      RESULT INT
    )
  LANGUAGE SQLSCRIPT
  SQL SECURITY INVOKER AS
BEGIN
  DECLARE TMP_VAR INT = 10;
  RETURN SELECT (:IP_A + :IP_B) * :TMP_VAR AS "RESULT" FROM DUMMY;
END;

In DSP is:

DECLARE TMP_VAR INT = 10;
RETURN SELECT (:IP_A + :IP_B) * :TMP_VAR AS "RESULT" FROM DUMMY;

The table definition and parameters are defined in the graphical interface, not in the code.

Regards,

michael_eaton3
Active Contributor
0 Likes

Remove the Begin and End

praveen_kumar334
Participant
0 Likes

Thanks michael.eaton3, error is cleared now. But I have seen some blogs where the SQLScript(Table Function) script code is embedded inside the Begin and End. Do we have any specific scenario where we need to embed the code in Begin and End ?