DO $$
DECLARE
    _typeId int;
BEGIN
    _typeId := (SELECT EntityId FROM vclib.T_ENTITIES WHERE EntName = 'SCHET_USL_83');
    INSERT INTO AKUZ.T_SCHET_USL_83 (SchetUslID, PR_II, PR_PAT)
    SELECT usl.SchetUslID, null, null
    FROM AKUZ.t_SCHET_USL usl
    WHERE usl.type_ = _typeId
    AND NOT EXISTS 
    (
        SELECT 1 
        FROM AKUZ.t_SCHET_USL_83 usl83
        WHERE usl83.SchetUslID = usl.SchetUslID
    );
END $$;