Reputation: 3
I would like to create a function within a function in native SAP HANA SQL
CREATE or REPLACE FUNCTION my_func (pi_param VARCHAR(1))
RETURNS v_return varchar(10) AS
BEGIN
DECLARE ....;
DECLARE ....;
FUNCTION my_local_func (pi_param INTEGER)
RETURNS v_return INTEGER AS
BEGIN
...
...
END;
END;
In Oracle PL/SQL I simply would declare my_local_func as well as local needed variables between "AS" and "BEGIN" of the my_func definition. This doesn't work in SAP HANA. Nor it doesn't work after the "BEGIN" section either (as stated here in this example).
So my question is, how to define a function within a function in native HANA SQL.
Upvotes: 0
Views: 165
Reputation: 10388
The reason for why this does not work in HANA is that HANA does not use PL/SQL as the procedural SQL extension language.
Instead, it has its own proprietary language, called SQLScript.
The syntax documentation uses Bakus-Naur form to lay out what commands can go into a procedure and local functions are not part of that.
In short: procedure local functions are not available in SQLScript. You can, however, define libraries and group functions into those.
Upvotes: 1