create or replace function Fn_GETRANDOMWID(DIMNAME in varchar2)
return number
is
result number;
begin
IF DIMNAME='DIM_VENDOR' THEN
select VENDOR_WID into result
from (select *
from DIM_VENDOR
where vendor_name like '%化工%'
order by dbms_random.random)
where rownum = 1;
ELSIF DIMNAME='PERSON_WID' THEN
select PERSON_WID into result
from (select *
from DIM_PER_ALL_PEOPLE
where department_name like '%SH原料经营%'
order by dbms_random.random)
where rownum = 1;
ELSE result:=0;
END IF;
RETURN result;
end Fn_GETRANDOMWID;
create or replace function F_IS_EoM return varchar2 is
Now date := sysdate;
Result varchar2(100);
begin
if (now = last_day(now)) then
result := to_char(now,'yyyy-mm-dd') || ' is the end of month.';
else
result := 'Today is ' || to_char(now,'yyyy-mm-dd') || '. ' ||
'The end of month in ' || to_char(last_day(now)-now) || ' day.';
end if;
return(Result);
end F_IS_EoM;