pg.ddx.io pgsql-sql@postgresql.org mailing list archivehelp / color / mirror / Atom feed
Syntax error in Execute statement 2+ messages / 2 participants [nested] [flat]
* Syntax error in Execute statement @ 2006-03-06 15:21 Emil Rachovsky <zsevgymko@yahoo.com> 0 siblings, 1 reply; 2+ messages in thread From: Emil Rachovsky @ 2006-03-06 15:21 UTC (permalink / raw) To: pgsql-general@postgresql.org <pgsql-general@postgresql.org>; +Cc: pgsql-sql Hello, I created a function "coalescec" which behaves the same as coalesce, but uses an integer and a string. Now I'm getting an error in the folowing statements : query := 'select "UID" from S_Users_To_Connection where ConnID = ' || coalescec(conn_id,'null'); execute query into nUID; ERROR: syntax error at or near "$2" at character 20 QUERY: SELECT $1 into $2 I have put UID in quotes because it seems to be a keyword. Here is the table script: create TEMP table S_Users_To_Connection( UID integer NOT NULL ,ConnID integer NOT NULL ,LoginID integer NOT NULL ); Any suggestions ? __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com ^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Syntax error in Execute statement @ 2006-03-06 18:30 Michael Fuhr <mike@fuhr.org> parent: Emil Rachovsky <zsevgymko@yahoo.com> 0 siblings, 0 replies; 2+ messages in thread From: Michael Fuhr @ 2006-03-06 18:30 UTC (permalink / raw) To: Emil Rachovsky <zsevgymko@yahoo.com>; +Cc: pgsql-general@postgresql.org <pgsql-general@postgresql.org>; pgsql-sql On Mon, Mar 06, 2006 at 07:21:58AM -0800, Emil Rachovsky wrote: > I created a function "coalescec" which behaves the > same as coalesce, but uses an integer and a string. Is there a reason you can't use the standard COALESCE and cast the integer value to text/varchar? > Now I'm getting an error in the folowing statements : > > query := 'select "UID" from S_Users_To_Connection > where ConnID = ' || coalescec(conn_id,'null'); > execute query into nUID; > > ERROR: syntax error at or near "$2" at character 20 > QUERY: SELECT $1 into $2 What version of PostgreSQL are you running? EXECUTE INTO is new in 8.1; earlier versions would print an error like the above. > I have put UID in quotes because it seems to be a > keyword. How did you determine that? UID isn't shown in the "SQL Key Words" appendix of the documentation and I don't see it in the backend or PL/pgSQL grammars. Using it unquoted works here: test=> CREATE TABLE foo (uid integer); CREATE TABLE test=> INSERT INTO foo (uid) VALUES (1); INSERT 0 1 test=> SELECT uid FROM foo; uid ----- 1 (1 row) I'd guess that you created the column with an uppercase quoted identifier. See the documentation regarding case folding and quoted identifiers: http://www.postgresql.org/docs/8.1/interactive/sql-syntax.html#SQL-SYNTAX-IDENTIFIERS -- Michael Fuhr ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2006-03-06 18:30 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2006-03-06 15:21 Syntax error in Execute statement Emil Rachovsky <zsevgymko@yahoo.com> 2006-03-06 18:30 ` Michael Fuhr <mike@fuhr.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox