/*Преобразует обычн ретрансляторы(коды дб заданы!!!) в Фобос ТР*/ SET TERM ^ ; create PROCEDURE TEMP_CONVERT_TO_TR AS DECLARE VARIABLE DVC INTEGER; DECLARE VARIABLE INP INTEGER; DECLARE VARIABLE PAR INTEGER; DECLARE VARIABLE VPAR INTEGER; begin for select CODE_DEVICE_LIST, PARENT_INPUT, PARENT_DEVICE_CODE from device_list where parent_device_code in(13979, 14058, 12865, 12837) and parent_input < 0 order by (-parent_input) into :dvc, :inp, :PAR DO begin if(bin_and(-:inp, 1) <> 0) then begin /*четный*/ update device_list set code_type_device=219, parent_input = (-:inp - 1)/2 +1 where code_device_list = :dvc; end else begin /*нечетный*/ vpar = null; select code_device_list from device_list where PARENT_DEVICE_CODE=:PAR and PARENT_INPUT = ((-:inp - 2)/2 +1) into :VPAR; if(:vpar is null) then begin /*нет четного*/ update device_list set code_type_device=219, parent_input = (-:inp - 2)/2 +1 where code_device_list = :dvc; end else begin /*есть четый*/ update device_list set code_type_device=219, parent_input = (-:inp - 2)/2 +1, virtual_parent = :vpar where code_device_list = :dvc; end /*zone*/ update device_list set zone_number=2 where parent_device_code = :dvc; end end end ^ SET TERM ; ^ update device_list set parent_input = -parent_input where parent_device_code in(13979, 14058, 12865, 12837); commit work; execute procedure TEMP_CONVERT_TO_TR; drop procedure TEMP_CONVERT_TO_TR;