您现在的位置是:网站首页> 编程资料编程资料
在Oracle PL/SQL中游标声明中表名动态变化的方法_Oracle应用_
2023-05-27
635人已围观
简介 在Oracle PL/SQL中游标声明中表名动态变化的方法_Oracle应用_
/*
小弟刚刚接触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;*/
您可能感兴趣的文章:
相关内容
- DBA_2PC_PENDING 介绍_Oracle应用_
- 在Oracle中向视图中插入数据的方法_Oracle应用_
- oracle 下WITH CHECK OPTION用法_Oracle应用_
- 浅谈LogMiner的使用方法_Oracle应用_
- oracle下加密存储过程的方法_Oracle应用_
- 在OracleE数据库的字段上建立索引的方法_oracle_
- 重新编译PLSQL中的无效对象或者指定的对象 的方法_oracle_
- Oracle轻松取得建表和索引的DDL语句_oracle_
- 如何保持Oracle数据库的优良性能_oracle_
- ORACLE 常用的SQL语法和数据对象_oracle_
