求一存储过程的写法
时间:2011-12-26
来源:互联网
求指点怎么把第一个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;
作者: smallprogrammer 发布时间: 2011-12-26
关于动态SQL语句,给你举个例子,请参考。

作者: LuiseRADL 发布时间: 2011-12-26
作者: smallprogrammer 发布时间: 2011-12-26
作者: smallprogrammer 发布时间: 2011-12-26
SQL code
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;
作者: tx2730 发布时间: 2011-12-26
作者: smallprogrammer 发布时间: 2011-12-26
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
作者: xpingping 发布时间: 2011-12-26
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
作者: zyuc_wangxw 发布时间: 2011-12-26
作者: CooperWu 发布时间: 2011-12-26
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28