"localhost:/firebird/data/ILICHEVSK2.FDB". Процедуры Previous topic Chapter index Next topic

OBJECTS_CREATEREFERENCES

 

Входные параметры

(Нет входных параметров)

 

Выходные параметры

(Нет выходных параметров)

 

Описание

(Нет описания для процедуры OBJECTS_CREATEREFERENCES)

 

Определение

CREATE PROCEDURE OBJECTS_CREATEREFERENCES
AS
DECLARE VARIABLE OBJRELATIONID INTEGER;
DECLARE VARIABLE OBJID INTEGER;
DECLARE VARIABLE OBJCLASSID INTEGER;
DECLARE VARIABLE NEWOBJID INTEGER;
DECLARE VARIABLE OBJNAME VARCHAR(50) CHARACTER SET WIN1251;
begin
  for
    SELECT OBJRelations.objrelationid, OBJECTS.OBJID, OBJCLASSID, Objects.objname
    FROM OBJECTS
    left join OBJRelations on Objects.ObjID = ObjRelations.OBJID
    where OBJRelations.ParentObjID = 13
    into :objrelationid, :OBJID, :OBJCLASSID, objname
  do
  begin
    if (:OBJCLASSID <> 3) then
      delete from objrelations where objrelationid = :objrelationid;
    else
    begin
      if (not exists (select * from objrelations
        left join objects on objrelations.objid = Objects.ObjID
        where objrelations.ParentObjID = :OBJID and Objects.objchildclassid = 8)) then
      begin
        NewObjID = GEN_ID(OBJECTIDGEN, 1);
        INSERT INTO OBJECTS (OBJID, OBJCLASSID, OBJSUBCLASSID, OBJCHILDCLASSID, OBJNAME, CAPTION, DESCRIPTION, OBJRIGHTS, OBJPARAMS, OBDATA, COMMENT)
        VALUES (:NewObjID, 2, 8, 8, :objname || 'ReferenceFolder', 'Справочники', NULL, NULL, NULL, NULL, NULL);
        insert into OBJRelations (OBJID, PARENTOBJID) values (:NewObjID, :ObjID);
      end
    end
  end
end

 

     Previous topic Chapter index Next topic