Home >Database >Mysql Tutorial >在Oracle PL/SQL中游标声明中表名动态变化的方法_Oracle应用_脚

在Oracle PL/SQL中游标声明中表名动态变化的方法_Oracle应用_脚

WBOY
WBOYOriginal
2016-06-07 18:04:211006browse

在Oracle PL/SQL中游标声明中表名动态变化的方法

/*
小弟刚刚接触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;*/
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn