我有这个程序:
CREATE OR REPLACE PROCEDURE CONV1(
pDate IN VARCHAR2,
pYear OUT number,
pMonth OUT number,
pDay OUT number
)
AS
lDate DATE;
BEGIN
lDate := to_date(pDate, 'DD.MM.YYYY HH24:MI:SS');
pYear := to_number(to_char(lDate, 'YYYY'));
pMonth := to_number(to_char(lDate, 'MM'));
pDay := to_number(to_char(lDate, 'DD'));
END CONV1;
/
如果我只想要其中一个出局,我该如何调用此程序?
(比如Select FMAN_STAT_CONV1('16.07.2010', pDay) from dual;
(这不是工作btw))
格尔茨!
答案 0 :(得分:6)
创建将使用过程conv1的函数,但只返回一个值。
甚至更适合您的特定情况
SELECT to_char(to_date(your_date, 'DD.MM.YYYY HH24:MI:SS'), 'DD') from dual.
或者常见的情况是:
CREATE OR REPLACE FUNCTION CONV2(
pDate IN VARCHAR2
)
RETURN NUMBER
IS
pDay number;
pMonth number;
pYear number;
BEGIN
conv1(pDate, pYear, pMonth, pDay);
return pDay;
END;