我有一个函数,它将table_name作为输入并返回一个数字。 该函数被正确编译但由于某些原因,当我尝试测试该函数时,它会抛出错误 - 缺少关键字。
CREATE OR replace FUNCTION TEST_FUNCTION (name_table IN VARCHAR2) RETURN NUMBER
IS
rday NUMBER;
BEGIN
execute immediate
'select day_i into rday
FROM ' || name_table || '
WHERE day_i = 1 and rownum = 1';
return rday;
END TEST_FUNCTION;
我正在测试它Select TEST_FUNCTION ('FDR_REP') from dual;
答案 0 :(得分:2)
对于into子句,execute immediate的语法不同 尝试
CREATE OR replace FUNCTION TEST_FUNCTION (name_table IN VARCHAR2) RETURN NUMBER
IS
rday NUMBER;
BEGIN
execute immediate 'select day_i
FROM ' || name_table || '
WHERE day_i = 1 and rownum = 1' into rday;
return rday;
END TEST_FUNCTION;