Is there any hack when inserting multidimensional array to postgres? I would like to insert smth like
INSERT INTO Timesheet (day, startTime, endTime, idSchedule)
VALUES(unnest(array['TUE', 'FRI']),
unnest(array[['10:00', '02:00'], ['10:00']]),
unnest(array[['14:00', '23:00'], ['14:00']]), 1);
Or in detail
INSERT INTO Timesheet (day, startTime, endTime, idSchedule)
VALUES('TUE', '10:00', '14:00', 1),
('TUE', '02:00', '23:00', 1),
('FRI', '10:00', '14:00', 1);
Query fails with
ERROR: multidimensional arrays must have array expressions with matching dimensions
Maybe there are any solutions?
You're probably looking for
INSERT INTO Timesheet (day, startTime, endTime, idSchedule)
VALUES(unnest(array['TUE', 'TUE', 'FRI']),
unnest(array['10:00', '02:00', '10:00']),
unnest(array['14:00', '23:00', '14:00']), 1);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With