Reputation: 1
My Function is getting a error but I don't know why ...
MY (DB2)SQL CODE:
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
... and passed successfully.
Upvotes: 0
Views: 46
Reputation: 1269873
You cannot reference row
in the where
. One method is a subquery:
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;
Upvotes: 1