我的功能出错,但我不知道为什么......
我的(DB2)SQL代码:
CREATE FUNCTION gibX(sseries INTEGER, idd INTEGER) RETURNS Double
BEGIN
Declare result Double;
SELECT ROW_NUMBER() OVER(ORDER BY m.x ASC) AS Row, m.x INTO result
FROM messungen m WHERE m.series=sseries and Row=idd;
return result;
END;
ERROR:的
CREATE FUNCTION;
return result;
;, DRIVER=4.13.80
...并顺利通过。
答案 0 :(得分:1)
您无法在row
中引用where
。一种方法是子查询:
SELECT x INTO result
FROM (SELECT ROW_NUMBER() OVER (ORDER BY m.x ASC) AS Row, m.x
FROM messungen m
WHERE m.series = sseries
) m
WHERE Row = idd;