要用动态的sql declare str varchar2(200); sql varchar2(200); begin str:='aa'; sql:='select '||str||'from '||str||' where aa='''||str||''' and ....'; execute immediate sql; end;
用了动态的SQL,还有错误????? v_tab_name :='sales'; v_str:='select count(*) from '||v_tab_name; /* dbms_output.put_line(v_str);*/ ----这个显示select count(*) from sales(没有;号) execute immediate v_str; end loop; end;ORA-06564: 对象 DATA_FILE_DIR 不存在 ORA-06512: 在line 31
这个错误不是动态SQL本身的问题.ORA-06564 object string does not existCause: The named object could not be found. Either it does not exist or you do not have permission to access it.Action: Create the object or get permission to access it.
declare
str varchar2(200);
sql varchar2(200);
begin
str:='aa';
sql:='select '||str||'from '||str||' where aa='''||str||''' and ....';
execute immediate sql;
end;
v_str:='select count(*) from '||v_tab_name;
/* dbms_output.put_line(v_str);*/ ----这个显示select count(*) from sales(没有;号)
execute immediate v_str;
end loop;
end;ORA-06564: 对象 DATA_FILE_DIR 不存在
ORA-06512: 在line 31