rax_m
September 9th, 2008, 02:35 PM
Hi all,
I inherited a database with a simple table from a colleague. Instead of manually uploading data, I decided to write a little java app (using netbeans) so we can regularly upload CSV files to it.
I was having issue with the insert statement and noticed this about the DDL of the table:
CREATE TABLE "Sea_temperature_recorders"
(
"Location" text,
"Date" date,
"Time" time,
"Temperature" float4,
"Instrument" text,
"Analyse" float4,
id int2 NOT NULL,
CONSTRAINT "Sea_temperature_recorders_pkey" PRIMARY KEY (id)
)
WITH OIDS;
ALTER TABLE "Sea_temperature_recorders" OWNER TO rmistry;
GRANT SELECT, UPDATE, INSERT, DELETE, REFERENCES, TRIGGER ON TABLE "Sea_temperature_recorders" TO xxxxx;
Notice the quotes around the table and column names. I assume the original person created it like this.
This causes an issue, as postgres doesn't like inserts unless the column and table names are quoted for every insert.
Internal Exception: org.postgresql.util.PSQLException: ERROR: syntax error at or near "Analyse"
Error Code: 0
Call: INSERT INTO Sea_temperature_recorders (id, Temperature, Location, Instrument, Time, Analyse, Date) VALUES (?, ?, ?, ?, ?, ?, ?)
bind => [0, 26.465, T1131, I1, 11:00:00, 0.0, 2007-03-27]
Is this normal ?? Should this be filed as a bug?
I'm guessing that it would be better to extract all of the data and re-create the tables (without quotes) and work from there.
Thanks
Rax
I inherited a database with a simple table from a colleague. Instead of manually uploading data, I decided to write a little java app (using netbeans) so we can regularly upload CSV files to it.
I was having issue with the insert statement and noticed this about the DDL of the table:
CREATE TABLE "Sea_temperature_recorders"
(
"Location" text,
"Date" date,
"Time" time,
"Temperature" float4,
"Instrument" text,
"Analyse" float4,
id int2 NOT NULL,
CONSTRAINT "Sea_temperature_recorders_pkey" PRIMARY KEY (id)
)
WITH OIDS;
ALTER TABLE "Sea_temperature_recorders" OWNER TO rmistry;
GRANT SELECT, UPDATE, INSERT, DELETE, REFERENCES, TRIGGER ON TABLE "Sea_temperature_recorders" TO xxxxx;
Notice the quotes around the table and column names. I assume the original person created it like this.
This causes an issue, as postgres doesn't like inserts unless the column and table names are quoted for every insert.
Internal Exception: org.postgresql.util.PSQLException: ERROR: syntax error at or near "Analyse"
Error Code: 0
Call: INSERT INTO Sea_temperature_recorders (id, Temperature, Location, Instrument, Time, Analyse, Date) VALUES (?, ?, ?, ?, ?, ?, ?)
bind => [0, 26.465, T1131, I1, 11:00:00, 0.0, 2007-03-27]
Is this normal ?? Should this be filed as a bug?
I'm guessing that it would be better to extract all of the data and re-create the tables (without quotes) and work from there.
Thanks
Rax