Create or Replace Function RAD_Get_AU_ID_By_Date(ADateFrom in date, ADateTo in date, ALocID in supermag.smstorelocations.id%type,AArticle in supermag.smcard.article%type)
return varchar2 is
l_str varchar2(2000) default null;
l_sep varchar2(1) default null;
BEGIN
for x in ( select au.id from supermag.SMSpecMA sp,supermag.smauctions au,SUPERMAG.SMAUCTIONATOMS d
where ((ADateFrom between trunc(au.datebegin) and trunc(au.dateend)) or (ADateTo between trunc(au.datebegin) and trunc(au.dateend)))
and sp.DOCID=au.ID and sp.Article=AArticle and d.LocID=ALocID and d.AUCID=AU.ID and D.doctype=AU.doctype) loop
l_str := l_str||l_sep||x.id;
l_sep := ',';
end loop;
return l_str;
EXCEPTION WHEN OTHERS THEN RETURN NULL;
end RAD_Get_AU_ID_By_Date;
/
commit;