PL/SQL怎么用变量引用已存在的表 老提示PLS-00357: 在此上下文中不允许表,视图或序列引用 '表名' 30
declareTnamevarchar2(10);dnonumber(6,2);v_sqlvarchar2(1000);typecurtypeisrefcursor;my...
declare
Tname varchar2(10);
dno number(6,2);
v_sql varchar2(1000);
type curtype is ref cursor;
mycur curtype;
v_rate varchar2(40);
begin
v_sql:='select sal from '||Tname||' where deptno='||dno;
open mycur for v_sql using &Tname,&dno;
loop fetch mycur into v_rate;
exit when mycur%notfound;
dbms_output.put_line(v_rate);
end loop;
close mycur;
end; 展开
Tname varchar2(10);
dno number(6,2);
v_sql varchar2(1000);
type curtype is ref cursor;
mycur curtype;
v_rate varchar2(40);
begin
v_sql:='select sal from '||Tname||' where deptno='||dno;
open mycur for v_sql using &Tname,&dno;
loop fetch mycur into v_rate;
exit when mycur%notfound;
dbms_output.put_line(v_rate);
end loop;
close mycur;
end; 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询