Inserting multiple rows wtih a SELECt in the values clause

Поиск
Список
Период
Сортировка
От stan
Тема Inserting multiple rows wtih a SELECt in the values clause
Дата
Msg-id 20191015135224.GA3910@panix.com
обсуждение исходный текст
Ответы Re: Inserting multiple rows wtih a SELECt in the values clause  (Andrew Gierth <andrew@tao11.riddles.org.uk>)
Список pgsql-general
OK, now that figured out how to return the constant, this is the final
query I need to run.


INSERT into rate
(
    employee_key ,
    project_key ,
    work_type_key ,
    rate
)
VALUES
(
    (
        SELECT 
        employee.employee_key , 
        project.project_key , 
        work_type.work_type_key , 
        1 as rate
    FROM employee 
    CROSS JOIN project 
    CROSS JOIN work_type
    )
);

But this fails.

I suspect this may be because the SELECT in the values clause returns
multiple rows?

-- 
"They that would give up essential liberty for temporary safety deserve
neither liberty nor safety."
                        -- Benjamin Franklin



В списке pgsql-general по дате отправления:

Предыдущее
От: Tomas Vondra
Дата:
Сообщение: Re: timescaleDB & WAL replication
Следующее
От: Geoff Winkless
Дата:
Сообщение: Re: SELECT returnig a constant