oracle在选择内部调用存储过程 [英] oracle call stored procedure inside select

查看:81
本文介绍了oracle在选择内部调用存储过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在处理一个查询(一个SELECT),我需要将此查询的结果插入表中. 在进行插入之前,我需要做一些检查,如果所有列都有效,我将进行插入.

I'm working on a query (a SELECT) and I need to insert the result of this one in a table. Before doing the insert I have some checking to do, and if all columns are valid, I will do the insert.

检查是在存储过程中完成的.在其他地方也使用相同的过程. 因此,我正在考虑使用相同的过程进行检查.

The checking is done in a stored procedure. The same procedure is used somewhere else too. So I'm thinking using the same procedure to do my checks.

程序进行检查并插入值都可以.

The procedure does the checkings and insert the values is all OK.

我试图在SELECT中调用该过程,但是它不起作用.

I tryied to call the procedure inside my SELECT but it does not works.

SELECT field1, field2, myproc(field1, field2)

from MYTABLE.

这种代码不起作用.

我认为可以使用游标完成此操作,但是我想避免使用游标. 我正在寻找最简单的解决方案.

I think it can be done using a cursor, but I would like to avoid the cursors. I'm looking for the easiest solution.

有人知道吗?

推荐答案

使用PL/SQL循环:

use a PL/SQL loop:

BEGIN
   FOR c IN (SELECT field1, field2 FROM mytable) LOOP
       my_proc(c.field1, c.field2);
   END LOOP;
END;

这篇关于oracle在选择内部调用存储过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆