Skip to Content
-1

HOW TO USE NULL IN ELSE PART IN SAP HANA?

Jan 29 at 05:16 AM

25

avatar image

Hi Experts,

I have a requirement to use null in else part of if condition.

Code:

CREATE PROCEDURE "KABIL_PRACTICE"."PROC_ELSE_NULL"(IN VAL1 INTEGER)
AS
BEGIN
IF :VAL1 >= 5 and :VAL1 <= 10
THEN
INSERT INTO "KABIL_PRACTICE"."ELSE_NULL" VALUES (:VAL1);
ELSE
NULL;
END;

but the above code throws an error in null line.

any suggestions please..??

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Florian Pfeffer
Jan 29 at 05:54 AM
0

Just writing NULL in the else case does not make sense very much and this causes the error, because you have no valid syntax with that.

The question is what you really wanna do if your condition is not fulfilled? Do you wanna do nothing, then just remove the else case. If you wanna insert a Null value in your table than do the insert statement with a Null value (of course the table column needs to accept Null values).

Regards,
Florian

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Thanks Florian Pfeffer ,

currently I'm working on a project which is converting oracle procedure to hana.... there they used null in else part of an if condition.

0

Syntax is not the same on Oracle and HANA. So no 1:1 copy and paste is possible.

So you should know what the Oracle coding do, to be able to re-implement it on HANA. My two questions from above remain, and I think if you answer the question yourself you have the solution.

0