您可以检查并告诉我为什么出现错误吗?它应该怎么看?我不知道这里有什么问题。我需要在一个函数来创建一个表,并在同一个函数将数据插入到这个表:'立即执行'子句中的'插入'
create or replace
function new_tab (pyt IN varchar2) return number
IS
a number;
b varchar2(20);
begin
a:= ROUND(dbms_random.value(1, 3));
b:='example';
-- This works perfect
execute immediate 'CREATE TABLE create_tmp_table'|| a ||'(i VARCHAR2(50))';
-- Here`s the problem
execute immediate 'insert into create_tmp_table'||a|| 'values ('|| b ||')';
exception
when others then
dbms_output.put_line('ERROR-'||SQLERRM);
return 0;
end;
我的结果是: ERROR-ORA-00926: missing VALUES keyword. Process exited.
哪里错了吗?
INSERT语句已经进入无关键字值或选择。 VALUES子句或SELECT子查询都必须遵循INSERT INTO子句。 – Aditya
我在|| a ||后面看到字值。 –