Re: big problem - Mailing list pgsql-general

From Mike Mascari
Subject Re: big problem
Date
Msg-id 3C8CEA01.2DCFB420@mascari.com
Whole thread Raw
In response to big problem  (Frank_Lupo Frank_Lupo <frank_lupo@telemail.it>)
List pgsql-general
Frank_Lupo Frank_Lupo wrote:
>
> Problem in insert
>
> CREATE TABLE "irelbcmb" (
> "id" int4,
> "id_pad" int4,
> "desc" int4,
> "cod" varchar(40),
> "sys_var" varchar(1),
> "nom_var" varchar(16)
> ) WITH OIDS;
>
> gedis30=# insert into irelbcmb (id,id_pad,desc,cod,sys_var,nom_var) values 1,1,1,"pippo","1","pippo");
> ERROR: parser: parse error at or near "desc"

PostgreSQL allowed for the CREATE TABLE with a column of "desc" because
you used double-quotes around the name. DESC is a keyword as in:

SELECT name
FROM employees
ORDER BY name DESC;
              ^^^^

Therefore, if you use it as a column, you must put double-quotes around
it in all your queries:

INSERT INTO irelbcmb (id, id_pad, "desc", cod, sys_var, nom_var)
VALUES (1, 1, 1, 'pippo','1','pippo');

Hope that helps,

Mike Mascari
mascarm@mascari.com

pgsql-general by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: big problem
Next
From: Bruce Momjian
Date:
Subject: Re: [HACKERS] Nice Oracle tuning article