你能告诉我为什么以下代码在PostgreSQL中不起作用吗?
See updated code below
更新:
我希望这个查询能够返回浮点数"0.30"。这个结构只是为了测试目的,我有一些依赖于这个条件结构的复杂查询... 但是我不知道如何修复它。
结果为:
ERROR: syntax error at or near "1"
LINE 4: if 1=1 then
更新:
这个结构出现在一个函数中...所以我想要做以下操作:
CREATE FUNCTION f_test(myvalue integer) RETURNS float AS $$
BEGIN
select (
case (select '1')
when '1' then
if 1=1 then
0.30::float
else
0.50::float
end
else
1.00::float
end
);
END;
$$ LANGUAGE plpgsql;
select f_test(1) as test;
上面有错误信息,请参考。