我正在尝试对PLSQL做一个非常基本的过程,但是当我尝试在SQL中使用它时,它将返回无效的标识符。
create or replace PROCEDURE YEARS_BETWEEN(date1 IN date , date2 IN date, p_result out number)
IS
v_months number;
BEGIN
v_months := months_between(date1, date2);
p_result := TRUNC(v_months / 12, 0);
END years_between;
谁能告诉我怎么了?
SQL IS
select YEARS_BETWEEN(GBDATUM, SYSDATE) as leeftijd FROM medewerkers;
答案 0 :(得分:4)
如果要在select
中调用它,则需要一个函数而不是一个过程:
create or replace function years_between (in_date1 in date , in_date2 in date)
return number as
v_months number;
begin
v_months := months_between(date1, date2);
return(trunc(v_months / 12, 0));
end; -- years_between