| From: | Richard Huxton <dev(at)archonet(dot)com> |
|---|---|
| To: | Eric Chacon <chaconeric(at)hotmail(dot)com> |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Function Won't Compile |
| Date: | 2001-07-11 06:53:21 |
| Message-ID: | 3B4BF7E1.9EDB8426@archonet.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Eric Chacon wrote:
>
> I'm sure I'm doing something stupid, but this is driving me nuts...
>
> This is the first stored procedure I've ever written in my life.
You're close, debugging plpgsql can be tricky:
> DROP FUNCTION update_flag_func();
> CREATE FUNCTION update_flag_func()
> RETURNS text
> AS 'UPDATE update_flag SET content=current_timestamp;'
> LANGUAGE 'plpgsql';
>
> SELECT update_flag_func();
>
> psql:udt:7: NOTICE: plpgsql: ERROR during compile of update_flag_func
> near line 1
> psql:udt:7: ERROR: parse error at or near "UPDATE"
You need a couple of things (untested):
... AS '
BEGIN
UPDATE update_flag SET content=current_timestamp;
RETURN ''OK'';
END;
' LANGUAGE 'plpgsql';
The BEGIN...END wrapper is needed as is a value to RETURN. There is an
example of this function in my PostgreSQL Notes at http://techdocs.postgresql.org/
HTH
- Richard Huxton
| From | Date | Subject | |
|---|---|---|---|
| Next Message | J.H.M. Dassen Ray | 2001-07-11 07:55:53 | Re: PostgreSQL hosting in the Netherlands |
| Previous Message | Martijn van Oosterhout | 2001-07-11 06:17:18 | Re: [PATCH] Partial indices almost there |