Обсуждение: Error with word 'desc'

Поиск
Список
Период
Сортировка

Error with word 'desc'

От
"Reuben D. Budiardja"
Дата:
Hi,
Seems that everytime I use the word 'desc' I got an error. For example, this
query:
SELECT code, desc FROM or_code_table WHERE tr = 'FORMAT'
gave me
ERROR:  parser: parse error at or near "desc"

When I created the table I got the same error too. I got around that by
creating the table using pgaccess instead of using psql console.

Is 'desc' a reserved key word of some kind ? Even if yes (like in mysql or
oracle), the parser should understand the context in which it's mentioned. I
don't remember I got that kind of error with mysql / oracle.

Here is the table:

lightcone=# \d or_code_table;
                Table "or_code_table"
  Column  |           Type           |   Modifiers
----------+--------------------------+---------------
 code     | character varying(2)     | not null
 tr       | character varying(10)    | not null
 desc     | character varying(100)   |
 mod_user | character varying(15)    |
 mod_time | timestamp with time zone | default now()
Primary key: or_code_table_pkey


Any help is greatly appreciated.

Thanks.

RDB

--
Reuben D. Budiardja
Department of Physics and Astronomy
The University of Tennessee, Knoxville, TN
-------------------------------------------------
/"\  ASCII Ribbon Campaign against HTML
\ /  email and proprietary format
 X   attachments.
/ \
-------------------------------------------------
Have you been used by Microsoft today?
Choose your life. Choose freedom.
Choose LINUX.
-------------------------------------------------


Re: Error with word 'desc'

От
Stephan Szabo
Дата:
On Tue, 24 Jun 2003, Reuben D. Budiardja wrote:

> Hi,
> Seems that everytime I use the word 'desc' I got an error. For example, this
> query:
> SELECT code, desc FROM or_code_table WHERE tr = 'FORMAT'
> gave me
> ERROR:  parser: parse error at or near "desc"
>
> When I created the table I got the same error too. I got around that by
> creating the table using pgaccess instead of using psql console.
>
> Is 'desc' a reserved key word of some kind ? Even if yes (like in mysql or
> oracle), the parser should understand the context in which it's mentioned. I
> don't remember I got that kind of error with mysql / oracle.

Desc is a reserved word.  You'll need to double quote it ("desc") in the
query for it to be legal.