我不知道如何创建用户定义的聚合函数,它应该完成相同的工作,例如我的存储过程。我的函数应该包含两个输入属性,有价格和计时器。 (抱歉我的英语不好)
我的程序是:
CREATE OR REPLACE PROCEDURE "PRICE"
(key IN NUMBER) AS
pricer ARTICLE.PRICE%type;
BEGIN
SELECT price INTO pricer
FROM HistoryPrice
WHERE Key_article =key AND TIMER=(select max(TIMER) FROM
HistoryPrice WHERE Key_article=key AND TIMER<=SYSDATE);
答案 0 :(得分:0)
格式如下。您需要更改select语句的逻辑。
CREATE OR REPLACE function f_price
(p_price IN NUMBER,
p_timer in number
) return number as
pricer ARTICLE.PRICE%type;
BEGIN
SELECT price INTO pricer
FROM HistoryPrice
WHERE Key_article =key AND TIMER=(select max(TIMER) FROM
HistoryPrice WHERE Key_article=key AND TIMER<=SYSDATE);
return pricer;
end;