在Oracle PL/SQL中游标声明中表名动态变化的方法
更新时间:2007年04月02日 00:00:00 作者:
/*
小弟刚刚接触ORACLE存储过程,有一个问题向各位同行求教,小弟写了一个存储过程,其目的是接收一个参数作为表名,然后查询该表中的全部记录的某一个字段的内容导入到另一个表中。
(
tabname in varchar
)
is
v_servicesname tabname.服务类型%type; --这个变量就是用来存放所要取得的字段内容,但不知该如何定义
cursor curSort1 is select 服务类型 from tabname order by 编码; --此语句也不对提示找不到表名
begin
.....
end getservicesname1;
An example:
create or replace procedure cal(tb varchar2) is
id pls_integer;
total pls_integer := 0;
type emp_cur is ref cursor;
cur emp_cur;
begin
open cur for 'select employee_id from ' || tb;
loop
fetch cur into id;
exit when cur%notfound;
total := total + id;
end loop;
close cur;
dbms_output.put_line(total)
end;*/
小弟刚刚接触ORACLE存储过程,有一个问题向各位同行求教,小弟写了一个存储过程,其目的是接收一个参数作为表名,然后查询该表中的全部记录的某一个字段的内容导入到另一个表中。
(
tabname in varchar
)
is
v_servicesname tabname.服务类型%type; --这个变量就是用来存放所要取得的字段内容,但不知该如何定义
cursor curSort1 is select 服务类型 from tabname order by 编码; --此语句也不对提示找不到表名
begin
.....
end getservicesname1;
An example:
create or replace procedure cal(tb varchar2) is
id pls_integer;
total pls_integer := 0;
type emp_cur is ref cursor;
cur emp_cur;
begin
open cur for 'select employee_id from ' || tb;
loop
fetch cur into id;
exit when cur%notfound;
total := total + id;
end loop;
close cur;
dbms_output.put_line(total)
end;*/
相关文章
Oracle row_number() over()解析函数高效实现分页
Oracle row_number() over()解析函数高效实现分页,需要的朋友可以参考下。2011-11-11
最新评论