是oracle里的存储过程
v_str_his_table_name varchar2(100);--是一个变量
v_str_his_table_name := 'aaa'
select * from v_str_his_table_name
v_str_his_table_name varchar2(100);--是一个变量
v_str_his_table_name := 'aaa'
select * from v_str_his_table_name
---------- ----------
1 6
2 7
3 8
4 9
5 10
6 11已选择6行。SQL> create or replace procedure show_t
2 as
3 v_str_his_table_name varchar2(100):='T';
4 str varchar2(100);
5 type t_cursor is ref cursor;
6 cursor1 t_cursor;
7 REC t%rowtype;
8 sqlstr1 varchar2(600);
9 begin
10 sqlstr1:='select * from '||v_str_his_table_name;
11 open cursor1 for sqlstr1;
12 loop
13 fetch cursor1 into rec;
14 exit when cursor1%notfound;
15 str:=lpad(rec.f1,8,' ')||lpad(rec.f2,8,' ');
16 dbms_output.put_line(str);
17 end loop;
18 close cursor1;
19 end;
20 /过程已创建。SQL> set serveroutput on size 1000000
SQL> call show_t();
1 6
2 7
3 8
4 9
5 10
6 11调用完成。
type cursorType is ref cursor;
end; create or replace procedure getemps(v_str_his_table_name varchar2, p_cursor in out types.cursorType )
as
str_sql varchar2(500);
begin
str_sql := 'select * from '||v_str_his_table_name ;
open productsinfo for str_sql;
end;