on 03-20-2013 7:13 AM
Dear Experts,
I am trying to create a sample function in SAP HANA . I am facing a problem while creating it.
It throws an error stating "
Could not execute 'CREATE FUNCTION GS_TEST (IP DECIMAL,OP DECIMAL) RETURNS DECIMAL LANGUAGE SQLSCRIPT AS v1 DECIMAL; ...' in 285 ms 343 µs . SAP DBTech JDBC: [257] (at 430): sql syntax error: incorrect syntax near ";": line 22 col 1 (at pos 430)
please help me here.
TIA
Regards,
Rajesh.
Hi Rajesh,
I am not completely sure if currently scalar type is implemented (thought it is mentioned in the documentation) as return data type. Can you please change it to table type like RETURNS table (a DECIMAL) and the return statement as
return select :v2 as a from dummy;
and check if it works.
Regards,
Ravi
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Ravi,
Thanks a lot for the response. I tried it as well it doesnt work.
CREATE FUNCTION "INF182285"."GS_TEST2" (IP DECIMAL,OP DECIMAL) RETURNS table (a DECIMAL)
LANGUAGE SQLSCRIPT AS
BEGIN
RETURN select 1.1 as a from dummy;
END;
This works. But when i add the code it causes problem.
CREATE FUNCTION "INF182285"."GS_TEST1" (IP DECIMAL,OP DECIMAL) RETURNS table (a DECIMAL)
LANGUAGE SQLSCRIPT AS
v1 DECIMAL;
v2 DECIMAL;
BEGIN
v2 := :IP;
v1 := :IP-:OP+0.6;
IF (v1 <> 0) THEN
IF (v1 > 0) THEN
WHILE (v1 <= 0) DO
v2 := v2-0.0001;
v1 := v2-:OP+0.6;
END WHILE;
ELSE IF (v1 < 0) THEN
WHILE (v1 >= 0) DO
v2 := v2+0.0001;
v1 := v2-:OP-0.6;
END WHILE;
END IF;
END IF;
RETURN select v2 as a from dummy;
END;
The error still persists.
Thanks,
Rajesh.
Please try the following:
CREATE FUNCTION FN_T1 (IP DECIMAL,OP DECIMAL) RETURNS table (a DECIMAL)
LANGUAGE SQLSCRIPT AS
v1 DECIMAL;
v2 DECIMAL;
BEGIN
v2 := :IP;
v1 := :IP-:OP+0.6;
IF (:v1 <> 0) THEN
IF (:v1 > 0) THEN
WHILE (:v1 <= 0) DO
v2 := :v2-0.0001;
v1 := :v2-:OP+0.6;
END WHILE;
ELSEIF (:v1 < 0) THEN
WHILE (:v1 >= 0) DO
v2 := :v2+0.0001;
v1 := :v2-:OP-0.6;
END WHILE;
END IF;
END IF;
RETURN select :v2 as a from dummy;
END;
Lars,
Where do we make a request for adding this feature to SAP HANA? There is not a category for SAP HANA on https://ideaplace.brightidea.com/. I am working on developing OLTP applications on SAP HANA and the XS engine but found that not having scalar type UDFs was a bit limiting. It would be nice to have them for the ROW store tables at a minimum. I am sure there are some reservations for implementing them on columnar store tables but I don't see why this would be an issue for the ROW store tables.
Thanks,
Jonathan Haun
I'm Sorry Lars. I did not imply that they were not going to be implemented. However, at the moment they are not available in SPS5. I was simply looking for a way to communicate the need to the product team and also get some indication as to when they will be available. If they already know its a need, that is great news.
Thanks for the comment.
User | Count |
---|---|
84 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.