【发布时间】:2016-11-24 14:47:43
【问题描述】:
我正在制作一个自定义函数来返回表格中一行的最大值:
CREATE OR REPLACE FUNCTION getMax
RETURN DECIMAL(3,2)
IS l_getMax DECIMAL(3,2);
BEGIN
SELECT MAX(PRICE)
INTO l_getMax
FROM TABLE;
RETURN l_getMax;
END getMax;
当我将数据类型设为整数时,它编译得很好,但后来我意识到它应该是小数,当我改变它时,我得到了以下错误:
Error(2,18): PLS-00103: Encountered the symbol "(" when expecting one of the following: . @ % ; is authid as cluster order using external character deterministic parallel_enable pipelined aggregate result_cache
Error(3,4): PLS-00103: Encountered the symbol "IS" when expecting one of the following: , * & - + / at mod remainder rem <an identifier> <a double-quoted delimited-identifier> <an exponent (**)> as from into || multiset bulk year day
Error(9,16): PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: end not pragma final instantiable order overriding static member constructor map
【问题讨论】:
-
只需将其设为
number。 Oracle 对numbers非常灵活。 -
RETURN DECIMAL(3,2)应该是RETURN DECIMAL -
@a_horse_with_no_name,你能把它作为答案吗?
-
@a_horse_with_no_name 我试过了,但它正在为我收集答案。最大值为 1.99,函数返回 2。
-
@GordonLinoff 谢谢! number 数据类型保留小数位,将其作为评论,我将接受它作为答案。
标签: sql oracle11g oracle-sqldeveloper