ITPub博客

首页 > 数据库 > Oracle > 2011-11-4 LEAST函数

2011-11-4 LEAST函数

Oracle 作者:hanaka 时间:2019-12-16 20:09:37 0 删除 编辑

http://www.itpub.net/thread-1499223-12-1.html

113楼


下面的选项都实现了这个过程:

CREATE OR REPLACE PROCEDURE plch_show_lowest (
   number1_in   IN NUMBER
, number2_in   IN NUMBER
, number3_in   IN NUMBER)
IS

哪一种能够显示传入的三个数中最小的一个?假设传给plch_show_lowest的实际值都不为空。

(A)

BEGIN
   DBMS_OUTPUT.put_line (
      LEAST (number1_in, LEAST (number2_in, number3_in)));
END;

(B)

BEGIN
   DBMS_OUTPUT.put_line (
      SMALLEST (number1_in, number2_in, number3_in));
END;

(C)

BEGIN
   DBMS_OUTPUT.put_line (
      MIN (number1_in, number2_in, number3_in));
END;

(D)

   l_lowest   NUMBER;
BEGIN
   SELECT LEAST (number1_in, number2_in, number3_in)
     INTO l_lowest
     FROM DUAL;
   DBMS_OUTPUT.put_line (l_lowest);
END;

(E)

   l_lowest   NUMBER := number1_in;
BEGIN
   IF number2_in < l_lowest
   THEN
      l_lowest := number2_in;
   END IF;
   IF number3_in < l_lowest
   THEN
      l_lowest := number3_in;
   END IF;
   DBMS_OUTPUT.put_line (l_lowest);
END;

(F)

BEGIN
   DBMS_OUTPUT.put_line (
      LEAST (number1_in, number2_in, number3_in));
END;


实测

B报错 PLS-00201: 必须声明标识符 'SMALLEST'

C报错 PLS-00103: 出现符号 ")"在需要下列之一时:   := . ( % ;  符号 "(" 被替换为 ")" 后继续。

ADEF均正确


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/680385/viewspace-2668888/ ,如需转载,请注明出处,否则将追究法律责任。

上一篇: 2011-11-3 触发器
请登录后发表评论 登录
全部评论

注册时间:2011-07-15

  • 博文量
    47
  • 访问量
    29232