Примерный шаблон. На современных СМ+ не проверено.
Код:
CREATE OR REPLACE PROCEDURE SUPERMAG.USR_INSPECT_1001 (
indoctype IN smdocuments.doctype%TYPE,
indocid IN smdocuments.id%TYPE,
inoldstate IN smdocuments.docstate%TYPE := NULL,
innewstate IN smdocuments.docstate%TYPE := NULL,
indummy IN core.smbool := NULL )
IS
INSPECT_ID supermag.ttinspectresbuffer.inspectid%TYPE := 1001;
BEGIN
INSPECT.ONSTARTTRANS;
INSERT INTO supermag.ttinspectresbuffer
(inspectid, errid, inspectname, errtext)
SELECT DISTINCT INSPECT_ID, 0, TO_CHAR(INSPECT_ID),
SUBSTR('Запрещено наценивание артикула ' || article || ' в группе ' || tree, 1, 255)
FROM ( SELECT s.article, sc.tree
FROM supermag.smspec s, supermag.smcard с, supermag.sacardclass sc
WHERE s.doctype=indoctype AND s.docid=indocid AND s.article=c.articler AND c.idclass=sc.id
AND sc.tree in (...)
);
INSPECT.SETFUNCNAME(INSPECT_ID);
END USR_INSPECT_1001;
/
-- Добавление процедуры в список супермаговских стандартных проверок
-- для документов 'AC', при смене статуса в "Принят к исполнению", по умолчанию у всех отключено
DECLARE
INSPECT_ID supermag.ssinspectfunc.id%TYPE := 1001;
INSPECT_NAME supermag.ssinspectfunc.name%TYPE := 'Пользовательская проверка 1001';
INSPECT_ORANAME supermag.ssinspectdoc.inspectoraname%TYPE := 'SUPERMAG.USR_INSPECT_1001';
INSPECT_DEFMODE supermag.ssinspectfunc.definspectmode%TYPE := 0;
BEGIN
insert into ssinspectfunc(id, name, definspectmode)
values (INSPECT_ID, INSPECT_NAME, INSPECT_DEFMODE);
insert into ssinspectdoc (doctype, docstate, docstatebefore, inspectid, inspectoraname, dobefore)
values ('AC', 2, 1, INSPECT_ID, INSPECT_ORANAME, 1);
commit;
END;
/