В копилку полезных запросов. Берем дерево команд Исследователя и получаем на выходе HTML код.
EXECUTE BLOCK
RETURNS(name VARCHAR(200))
AS
DECLARE VARIABLE prev_indent INTEGER = 0;
DECLARE VARIABLE indent INTEGER;
DECLARE VARIABLE I INTEGER;
DECLARE VARIABLE n VARCHAR(200);
BEGIN
name = '
';
SUSPEND;
FOR
WITH RECURSIVE
group_tree AS (
SELECT id, parent, name,
CAST('' AS VARCHAR(255)) AS indent
FROM gd_command
WHERE parent IS NULL
UNION ALL
SELECT g.id, g.parent, g.name,
h.indent || rpad('', 2)
FROM gd_command g JOIN group_tree h
ON g.parent = h.id
)
SELECT
CHARACTER_LENGTH(gt.indent),
TRIM(gt.name)
FROM
group_tree gt
INTO :indent, :n
DO BEGIN
I = :indent - :prev_indent;
IF (:I > 0) THEN
BEGIN
name = '';
SUSPEND;
prev_indent = :indent;
END
IF (:I < 0) THEN
BEGIN
name = '
';
SUSPEND;
prev_indent = :indent;
END
name = '- ' || :n || '
';
SUSPEND;
END
name = '
';
SUSPEND;
END
Комментариев нет:
Отправить комментарий