oracle过程返回整数 [英] oracle procedure returns integer

查看:130
本文介绍了oracle过程返回整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在oracle中,我想创建一个删除程序,该程序根据删除的结果返回一个整数.

In oracle, I want to create a delete sproc that returns an integer based on the outcome of the deletion.

这是我到目前为止所拥有的.

this is what i have so far.

create or replace
PROCEDURE Testing
( 
iKey IN VARCHAR2
)
 AS 

BEGIN
  delete from MyTable WHERE 
  TheKey = iKey;

END Testing;

我曾尝试将RETURNS INTEGER放入其中,但存储过程将无法编译.

i've tried putting a RETURNS INTEGER in but the sproc won't compile.

推荐答案

使用函数和隐式SQL游标确定删除的行数

Use a function and the implicit SQL cursor to determine the number of rows deleted

create or replace
FUNCTION Testing
( 
iKey IN VARCHAR2
) RETURN INTEGER
 AS 

BEGIN
  delete from MyTable WHERE 
  TheKey = iKey;

  RETURN SQL%ROWCOUNT;

END Testing;

应该可以

这篇关于oracle过程返回整数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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