想写一存储过程,实现如下功能:
求指点怎么把第一个SQL查询出的字段值,作为第二次查询的参数 BEGIN
select 字段1, 字段2, 字段3 from 表A where code='test'
--把字段1、字段2、字段3 作为参数 带入第二个SQL语句open RC_P for select * from 表2 where rownum <=字段1 and code=字段2 order by 字段3 desc
END HOT;
求指点怎么把第一个SQL查询出的字段值,作为第二次查询的参数 BEGIN
select 字段1, 字段2, 字段3 from 表A where code='test'
--把字段1、字段2、字段3 作为参数 带入第二个SQL语句open RC_P for select * from 表2 where rownum <=字段1 and code=字段2 order by 字段3 desc
END HOT;
解决方案 »
- 请教一个存储过程,查询判断的,求高手赐教啊
- 关于oracle和PB是否可以使用中间件?
- centos oracle 10g dbca后,只能选择创建数据库,数据库配置和删除灰色
- 菜鸟求助!关于VC远程连接Oracle的。
- 紧急````````
- 外键定义联合主键的问题
- 从Oralce数据库中导出的日期型数据多了一个0,将此数据导入进数据库中报ORA-01830错误。
- 怎么把SQL SERVER中的一个数据库的表格,数据导到Oracle的一个方案中
- 请推荐你认为最好的两本oracle教材及两本oracle参考资料,请不要多推荐
- 如何实现控制某段时间内可以使用
- 冰天雪地跪地求教
- expdp 导出失败
关于动态SQL语句,给你举个例子,请参考。
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;
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
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
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