CREATE TEMP TABLE tmp (
    shortcutid UUID,
    commandname VARCHAR(255),
    keys VARCHAR(255),
    formtype VARCHAR(255),
    context VARCHAR(255),
    stronglycached BOOLEAN,
    userid UUID
);

INSERT INTO tmp (shortcutid, commandname, keys, formtype, context, stronglycached, userid)
VALUES
    (gen_random_uuid(), 'DEBUG_MODE', 'F9, Shift, Control, Alt', NULL, NULL, FALSE, NULL),
    (gen_random_uuid(), 'Просмотр произвольного списка', 'F12', NULL, NULL, FALSE, NULL),
    (gen_random_uuid(), 'Окна...', 'Tab, Control', NULL, NULL, FALSE, NULL),
    (gen_random_uuid(), 'Закрыть', 'W, Control', NULL, NULL, FALSE, NULL),
    (gen_random_uuid(), 'Восстановить вкладку', 'T, Shift, Control', NULL, NULL, FALSE, NULL),
    (gen_random_uuid(), 'Сохранить', 'S, Control', NULL, NULL, TRUE, NULL),
    (gen_random_uuid(), 'Удалить', 'Delete, Shift', NULL, NULL, TRUE, NULL);

INSERT INTO vclib.t_shortcutcommand (shortcutid, commandname, keys, formtype, context, stronglycached, userid)
SELECT 
    t.shortcutid,
    t.commandname,
    t.keys,
    t.formtype,
    t.context,
    t.stronglycached,
    t.userid
FROM tmp t
WHERE NOT EXISTS (
    SELECT 1 
    FROM vclib.t_shortcutcommand sc 
    WHERE sc.commandname = t.commandname 
      AND sc.keys = t.keys 
      AND t.formtype IS NULL 
      AND t.context IS NULL 
      AND t.stronglycached = sc.stronglycached 
      AND sc.userid IS NULL
);

DROP TABLE tmp;