Re: error: insert has more expressions than target column

Поиск
Список
Период
Сортировка
От Richard Huxton
Тема Re: error: insert has more expressions than target column
Дата
Msg-id 413DC53D.3030202@archonet.com
обсуждение исходный текст
Ответ на Re: error: insert has more expressions than target column  (Dino Vliet <dino_vliet@yahoo.com>)
Ответы Re: error: insert has more expressions than target column  (Dino Vliet <dino_vliet@yahoo.com>)
Список pgsql-general
Dino Vliet wrote:
> I'm getting the same error without brackets.

Check the columns in table "lessons" matches the columns in your select.

> The EXECUTE statement was because I read something
> about executing dynamic content.
>
> I want to add 7 days to the date value of startdate
> and want to repeat it every week. Because there are 8
> weeks I choose to do that with the for loop going from
> 0 to 7.

Looking closer, I can see the problem. You're treating the column from
the select as a variable (which it isn't).

Try something like:

INSERT INTO lessons (col_name1, col_name2, ...)
SELECT dayofweek, startdate + (i*7), endate + (i*7), startime, ...

--
   Richard Huxton
   Archonet Ltd

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

Предыдущее
От: Dan Sugalski
Дата:
Сообщение: explain with placeholders?
Следующее
От: Jeff Boes
Дата:
Сообщение: Re: HOWTO: Get a table or database definition