Теперь встал другой вопрос -
как избавиться от ORA-14551: cannot perform a DML operation inside a query
сама функция:
Create or Replace Function Article_LastDocID2(MyStoreloc IN SUPERMAG.SMSTORELOCATIONS.ID%TYPE, MyArticle IN SUPERMAG.SMCARD.ARTICLE%TYPE)
return VARCHAR2 is
res_all varchar2 (100);
res_tt integer:=0;
BEGIN
select count(*) into res_tt from supermag.TTREMAINS;
if res_tt=0 then
supermag.Rep_Ostatki(to_char(sysdate-1,'dd.mm.yyyy'),0,0,0,2,0,0,0);
commit;
end if;
select D.ID into res_all from SUPERMAG.TTOSTATKI1 D where D.LOCID=MyStoreloc and D.ARTICLE=MyArticle;
RETURN res_all;
EXCEPTION WHEN NO_DATA_FOUND THEN RETURN NULL;
END Article_LastDocID2;
/