如何使用 SELECT 从 Oracle 存储过程返回行?
我有一个返回引用游标的存储过程,如下所示:
CREATE OR REPLACE PROCEDURE AIRS.GET_LAB_REPORT (ReportCurTyp OUT sys_refcursor)
AS
v_report_cursor sys_refcursor;
report_record v_lab_report%ROWTYPE;
l_sql VARCHAR2 (2000);
BEGIN
l_sql := 'SELECT * FROM V_LAB_REPORT';
OPEN v_report_cursor FOR l_sql;
LOOP
FETCH v_report_cursor INTO report_record;
EXIT WHEN v_report_cursor%NOTFOUND;
END LOOP;
CLOSE v_report_cursor;
END;
我想在另一个选择语句中使用此存储过程的输出,例如:
SELECT * FROM GET_LAB_REPORT()
但我似乎无法理解语法。
有什么想法吗?
I have a stored procedure which returns a ref cursor as follows:
CREATE OR REPLACE PROCEDURE AIRS.GET_LAB_REPORT (ReportCurTyp OUT sys_refcursor)
AS
v_report_cursor sys_refcursor;
report_record v_lab_report%ROWTYPE;
l_sql VARCHAR2 (2000);
BEGIN
l_sql := 'SELECT * FROM V_LAB_REPORT';
OPEN v_report_cursor FOR l_sql;
LOOP
FETCH v_report_cursor INTO report_record;
EXIT WHEN v_report_cursor%NOTFOUND;
END LOOP;
CLOSE v_report_cursor;
END;
I want to use the output from this stored procedure in another select statement like:
SELECT * FROM GET_LAB_REPORT()
but I can't seem to get my head around the syntax.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
每当我不得不这样做时;我使用过 Oracle TYPE 和 CAST 功能。
类似于:
您需要设置类型和您需要的所有列,并让它们使用:
来捕获您的数据。有很多方法可以做到这一点,如果我能找到一个更好的例子,我会的,但这可能会给你一个想法。
Whenever I've had to do this; I've used the Oracle TYPE and CAST features.
Something like:
You need to setup the TYPE and all the columns you need and have them use:
to capture your data. There are many ways to do this and if I can dig out a better example I will but this might give you an idea.
请参阅此 SO 以获取工作示例:Oracle 参数带有 IN 语句?
See this SO for a working example: Oracle Parameters with IN statement?