dbTalk Databases Forums  

Re: [BUGS] BUG #2224: unlogical syntax error

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] BUG #2224: unlogical syntax error in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] BUG #2224: unlogical syntax error - 01-30-2006 , 09:20 AM






"Hervé Hénoch" <h.henoch (AT) isc84 (DOT) org> writes:
Quote:
CETLOG: statement: PREPARE <unnamed> AS SELECT adm_pat."nip", id_caisse
caisse FROM adm_pat WHERE nip = '20020523'

CETERROR: syntax error at or near "caisse" at character 33
"AS" before a column alias is not optional in Postgres.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 4: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] BUG #2224: unlogical syntax error - 01-30-2006 , 11:12 AM






On Mon, Jan 30, 2006 at 10:47:10AM +0000, Herv Hnoch wrote:
Quote:
CETLOG: statement: PREPARE <unnamed> AS SELECT adm_pat."nip", id_caisse
caisse FROM adm_pat WHERE nip = '20020523'

CETERROR: syntax error at or near "caisse" at character 33
Are you writing this query or is JDBC generating it? The AS keyword
is required for column aliases; its absence is causing the syntax
error.

test=> CREATE TABLE foo (abc text);
test=> SELECT abc AS xyz FROM foo;
xyz
-----
(0 rows)

test=> SELECT abc xyz FROM foo;
ERROR: syntax error at or near "xyz" at character 12
LINE 1: SELECT abc xyz FROM foo;
^

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 3: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faq


Reply With Quote
  #3  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] BUG #2224: unlogical syntax error - 01-31-2006 , 02:37 PM



[Please copy the mailing list on replies.]

On Tue, Jan 31, 2006 at 08:53:44AM +0100, Hnoch Herv wrote:
Quote:
Thank for you response .... I have never written this query : I think it
is JDBC that have generated it ... My query (written by me) is :

select id_caisse as caisse from FROM adm_pat WHERE nip = '20020523'

I know I have to use "as" statement ... I'd never disturb you for a
simple syntax error ...
The above query does have a syntax error ("from FROM"), although
the query in your original report looked correct.

Quote:
Jdbc version : jdbc3 8.1.404
I downloaded postgresql-8.1-404.jdbc3.jar onto a Solaris 9 box
running PostgreSQL 8.1.2 and wrote a test program to run your
original query:

select id_caisse as caisse from adm_pat where nip = '20020523'

The query ran successfully and logged the following:

LOG: statement: PREPARE <unnamed> AS select id_caisse as caisse from adm_pat where nip = '20020523'
LOG: statement: <BIND>
LOG: statement: EXECUTE <unnamed> [PREPARE: select id_caisse as caisse from adm_pat where nip = '20020523']

Quote:
The very stange think is, if I write :

select nip, id_caisse as caisse from FROM adm_pat WHERE nip = '20020523'

There is no syntax error !!!!!
There should be a syntax error due to "from FROM"; please post the
actual queries you're running. It might also be helpful if you
could post a simple but complete program so we can see everything
you're doing. You might also try asking in the pgsql-jdbc list to
see if anybody there has heard of this problem.

--
Michael Fuhr

---------------------------(end of broadcast)---------------------------
TIP 6: explain analyze is your friend


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.