From: | "Thalis A(dot) Kalfigopoulos" <thalis(at)cs(dot)pitt(dot)edu> |
---|---|
To: | Nicolas Drapeau <ndrapeau(at)travelnet(dot)ca> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Parsing error |
Date: | 2001-07-11 16:58:59 |
Message-ID: | Pine.LNX.4.21.0107111252320.7168-100000@aluminum.cs.pitt.edu |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
> ze_database=> CREATE TABLE my_table (
> ze_database(> p1 integer,
> ze_database(> p2 integer,
> ze_database(> p3 integer,
> ze_database(> p4 integer);
> CREATE
> ze_database=> CREATE FUNCTION my_add(integer,integer,integer,integer)
> ze_database-> RETURNS integer
> ze_database-> AS 'INSERT INTO my_table VALUES ($1,$2,$3,$4); SELECT 1'
> ze_database-> LANGUAGE 'sql';
> CREATE
> ze_database=> CREATE FUNCTION my_update(integer,integer,integer,integer)
> ze_database-> RETURNS integer
> ze_database-> AS 'SELECT CASE WHEN UPDATE my_table SET p1= $1, p2= $2 WHERE
> p3= $3 AND p4= $4 ~* \'UPDATE 0\' THEN my_add($1,$2,$3,$4) ELSE 1 END'
> ze_database-> LANGUAGE 'sql';
> ERROR: parser: parse error at or near "my_table"
> ze_database=>
You are not allowed to have an SQL query in a CASE clause. The condition after WHEN must be an expression that returns a boolean. You would be better off using plpgsql for something like what you want.
cheers,
thalis
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2001-07-11 17:09:17 | Re: dropping sequence with the table |
Previous Message | Bruce Momjian | 2001-07-11 16:55:07 | Re: [PATCH] Partial indices almost there |