tags:

views:

104

answers:

3

I'a using PostgreSQL 8.1.11

AND I'm loosing my mind why I can not use a basic SQL statement as INSERT

I provide:

INSERT INTO the_leads_details ( id, lead_id, question_id, i_value, c_value ) VALUES
( 1, 1, 1, NULL, '4500' ), ( 2, 1, 2,    1, NULL );

                         ^ this coma is a problem

What I am missing ? This seems like a basic SQL INSERT statement to insert multiple rows, Is it related to PostgreSQL version ?

I am inserting a lot of rows and I looking to optimize INSERT multiple rows instead place several INSERTs

Bensiu

A: 

The syntax is correct, are you sure that the problem is in the comma?

vulkanino
+5  A: 

Multi-row INSERT syntax is not supported in PostgreSQL 8.1, you need to upgrade to 8.2 or newer (and if you upgrade today, you really should upgrade to 8.4, not 8.2!)

Another reason is, as Frank mentioned in a comment, that version 8.1 will go end-of-life in November, so it's really time to start investigating upgrading.

Magnus Hagander
+1  A: 

I'm not sure Postgresl 8.1 supports multiple rows in VALUES. The syntax is:

INSERT INTO table [ ( column [, ...] ) ]
    { DEFAULT VALUES | VALUES ( { expression | DEFAULT } [, ...] ) | query }

http://www.postgresql.org/docs/8.1/static/sql-insert.html

Edmund