Дерево страниц
Skip to end of metadata
Go to start of metadata

Вы просматриваете старую версию данной страницы. Смотрите текущую версию.

Сравнить с текущим просмотр истории страницы

« Предыдущий Версия 29 Следующий »

Описаны наиболее востребованные блоки SQL-запросов

Статус

ДОРАБОТКА

Раздел


Кастомный атрибут основных объектов

ЗначенияSQL - запрос

Текст

В запросе используется {storage-field name} значение которого берется из атрибута storage-field
tn_field_string
select tfs."value" as v
from tn_field_string tfs
join tn_field tf on tf.id = tfs.id
where tf.owner = rkkbase.id and tf.owner_type = rkkbase.id_type and tf.cmjfield = '{storage-field name}'

Число

В запросе используется {storage-field name} значение, которого берется из атрибута storage-field
tn_field_decimal
select tfd."value" as v
from tn_field_decimal tfd
join tn_field tf on tf.id = tfd.id 
where tf.owner = rkkbase.id and tf.owner_type = rkkbase.id_type and tf.cmjfield = '{storage-field name}'

Дата

В запросе используется {storage-field name} значение которого берется из атрибута storage-field
tn_field_dateonly
select tfs."value" as v
from tn_field_dateonly tfd
join tn_field tf on tf.id = tfd.id
where tf.owner = rkkbase.id and tf.owner_type = rkkbase.id_type and tf.cmjfield = '{storage-field name}'

Время

В запросе используется {storage-field name} значение которого берется из атрибута storage-field
tn_field_timeonly
select tfs."value" as v
from tn_field_timeonly tft
join tn_field tf on tf.id = tft.id
where tf.owner = rkkbase.id and tf.owner_type = rkkbase.id_type and tf.cmjfield = '{storage-field name}'

Дата и время

В запросе используется {storage-field name} значение которого берется из атрибута storage-field
tn_field_datetime
select tfs."value" as v
from tn_field_datetime tfdt
join tn_field tf on tf.id = tfdt.id
where tf.owner = rkkbase.id and tf.owner_type = rkkbase.id_type and tf.cmjfield = '{storage-field name}'

Субъект СО

В запросе используется {storage-field name} значение которого берется из атрибута storage-field
tn_field_string
coalesce((select string_agg(SPLIT_PART(tfs.value, '%', 1),',') as v
 			from tn_field_string tfs
 			join tn_field tf on tf.id = tfs.id
 			where tf.owner = rkkbase.id and tf.owner_type = rkkbase.id_type 
			and tf.cmjfield = '{storage-field name}'),'Не указано')


Атрибут комплексного справочника

Все атрибуты комлескного справочника текстовые.

ЗначенияSQL - запрос

Текст

В запросе используется {storage-field name} значение которого берется из атрибута storage-field
classifier_complex
(select title from classifier_complex where classifier_complex.id = (
      					select complex1.id
						from clscom_tag tag1
						left join clscom_to_tag to_tag1 on to_tag1.tag = tag1.id
						left join classifier_complex complex1 on complex1.id = to_tag1.classifier
						left join cls_typeComp typecom1 on typecom1.id = complex1.owner
						where tag1.schema = 'ComplectClassifierWP'
						and typecom1.alias = '{storage-field name}' and tag1.id = tag.id)) as Office


Конвертация cmjunid в id и id_type

Данную конструкцию нельзя использовать в разработке на SQL, так как она влияет на производительность. Используется только для анализа.

ЗначенияSQL - запрос

Таблица

В запросе используется {table name}, которая заменяется на базовые таблицы: f_dp_rkk (РКК), f_dp_resolution (Резолюции), f_dp_execution (Исполнения)

select doti."name", 
  	map.notesunid,
	cmj_document.id, 
	cmj_document.id_type
from {table name} cmj_document 
join (
	select SUBSTRING(npm.punid FOR 16) as sochiunid, 
	npm.nunid as notesunid
	from nunid2punid_map npm) map on to_char(cast((cmj_document.id_type * 10^12) as bigint) + cmj_document.id, 'FM0000000000000000') = map.sochiunid
join domain_object_type_id doti on doti.id  = cmj_document.id_type

  • Нет меток