oracle存储过程中使用动态游标的问题
豪杰笑开怀 2009-01-07 12:04:49 存储过程如下:
CREATE OR REPLACE PROCEDURE p_test
is
TYPE t_rec_date IS TABLE OF raw_data.stock_date%type INDEX BY BINARY_INTEGER;
TYPE t_ref_cursor IS REF CURSOR;
v_cur t_ref_cursor;
v_sql string(2000);
v_stock_date date;
begin
v_sql := 'select stock_date from raw_data';
open v_cur for v_sql;
loop
fetch v_cur into v_stock_date;
exit when v_cur%notfound;
end loop;
close v_cur;
end p_test;
报的是"open v_cur for v_sql;"这行有错,错误如下:
PROCEDURE P_TEST 出现错误:
LINE/COL ERROR
-------- -----------------------------------------------------------------
11/2 PLS-00103: 出现符号 ""在需要下列之一时:
begin case declare end
exception exit for goto if loop mod null pragma raise return
select update while with <an identifier>
<a double-quoted delimited-identifier> <a bind variable> <<
close current delete fetch lock insert open rollback
savepoint set sql execute commit forall merge
<a single-quoted SQL string> pipe
奇怪的是,我因为建了两个oracle9i的库,两个库完全一致,一个在公司,一个在家里,在公司运行如上存储过程没有问题,但是在家里运行就报错,区别只是公司我使用的是oracle10g client,而家里使用的是9i的client,难道存储过程的编译和client还有关系?
实在搞不懂,请各位大虾指教!!!