日期:2014-05-17 浏览次数:20803 次
DECLARE TYPE ref_cursor_type IS REF CURSOR; ref_cursor_type RC_P; v_1 表A.字段1%TYPE; v_2 表A.字段2%TYPE; v_3 表A.字段3%TYPE; BEGIN SELECT 字段1, 字段2, 字段3 INTO v_1, v_2, v_3 FROM 表A WHERE code = 'test'; --只能有一行记录被找到,否则会报错 OPEN RC_P FOR 'select * from 表2 where rownum <=' || v_1 || ' and code=''' || v_2 || ''' order by ' || v_3 || ' desc'; END;
------解决方案--------------------
procedure HOT is filed1 table_A.字段1%type; filed2 table_A.字段2%type; filed3 table_A.字段3%type; begin select 字段1, 字段2, 字段3 into filed1,filed2,filed3 from table_A where code='test'; open RC_P for select * from 表2 where rownum <=filed1 and code=filed2 order by filed3 desc; end HOT
------解决方案--------------------
procedure HOT
is
filed1 table_A.字段1%type;
filed2 table_A.字段2%type;
filed3 table_A.字段3%type;
begin
select 字段1, 字段2, 字段3
into
filed1,filed2,filed3
from table_A where code='test';
open RC_P for select * from 表2 where rownum <=filed1 and code=filed2 order by filed3 desc;
end HOT
------解决方案--------------------
看见代码中的中文就晕。
------解决方案--------------------
procedure HOT
is
filed1 table_A.字段1%type;
filed2 table_A.字段2%type;
filed3 table_A.字段3%type;
begin
select 字段1, 字段2, 字段3
into
filed1,filed2,filed3
from table_A where code='test';
open RC_P for select * from 表2 where rownum <=filed1 and code=filed2 order by filed3 desc;
end HOT