HANA数据库进行IF...ELSE语法
困扰了我一个多星期的HANA 存储过程的IF判断问题,经过公司DB指导,解决这一难题。
错误写法1:
BEGIN
DECLARE count1 INT = 0;
select count(*) as count1 from tableName;
IF :count1 <> 0 THEN
var_out = select * from tableName where 条件;(true的情况)
ELSE
var_out = select * from tableName where 条件;(false的情况)
END IF;
END;
错误写法2:
BEGIN
DECLARE count1 INT = 0;
:count1 = select count(*) from tableName;
IF :count1 <> 0 THEN
var_out = select * from tableName where 条件;(true的情况)
ELSE
var_out = select * from tableName where 条件;(false的情况);
END IF;
END;
正确写法:
BEGIN
DECLARE count1 INT = 0;
select count(*) into count1 from tableName;
IF :count1 <> 0 THEN
var_out = select * from tableName where 条件;(true的情况)
ELSE
var_out = select * from tableName where 条件;(false的情况)
END IF;
END;
post SAP-Garson
原文链接:https://blog.csdn.net/weixin_42307382/article/details/84580255文章来自于网络,如果侵犯了您的权益,请联系站长删除!