From: | Michael Fuhr <mike(at)fuhr(dot)org> |
---|---|
To: | Emil Rachovsky <zsevgymko(at)yahoo(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>, "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Syntax error in Execute statement |
Date: | 2006-03-06 18:30:42 |
Message-ID: | 20060306183042.GA14001@winnie.fuhr.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general 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
From | Date | Subject | |
---|---|---|---|
Next Message | metadev | 2006-03-06 18:41:20 | Re: Using same database from XP and Linux in notebook |
Previous Message | Steve Atkins | 2006-03-06 17:44:50 | Re: Using same database from XP and Linux in notebook |
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 2006-03-07 02:39:18 | Re: problem with overloading the "coalesce" function |
Previous Message | Greg Stark | 2006-03-06 15:55:31 | Re: Help with "missing FROM clause" needed |