Re: Error in insert statement

Поиск
Список
Период
Сортировка
От Thomas Kellerer
Тема Re: Error in insert statement
Дата
Msg-id h3o15j$a0j$1@ger.gmane.org
обсуждение исходный текст
Ответ на Error in insert statement  ("Relyea, Mike" <Mike.Relyea@xerox.com>)
Ответы Re: Error in insert statement
Список pgsql-general
Relyea, Mike wrote on 16.07.2009 21:40:
> I need help understanding what I'm doing wrong with an insert statement.
> I'm running 8.3.7 on Windows and the DB is complaining about the select
> statement in my insert statement.

When using a SELECT for an INSERT the values part is not needed in fact its
incorrect syntax.

You need to run:

INSERT INTO "tblSpecs"
("CartridgeTypeID", "ColorID", "TestTypeID",
"ZoneID", "PaperID", "AttributeID", "Spec")
SELECT * FROM "tblTempSpecs";

But: using a "SELECT *" here is calling for trouble. You are relying on an
implicit an not guaranteed order and number of columns.

Listing all the needed columns in the SELECT statement is much more robust.

Btw: you should create your tables without using double quotes, thus you can get
rid of them when doing normal DML.

Out of curiosity: why do you prefix the table with "tbl"? Don't you know it's a
table? Sounds like a strange naming scheme to me.

Thomas

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

Предыдущее
От: bricklen
Дата:
Сообщение: Re: Error in insert statement
Следующее
От: "Relyea, Mike"
Дата:
Сообщение: Re: Error in insert statement