Re: Stored Procedure Newbie

From: Stephan Szabo <sszabo(at)megazone23(dot)bigpanda(dot)com>
To: Eric Chacon <chaconeric(at)hotmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Stored Procedure Newbie
Date: 2001-07-10 22:54:27
Message-ID: Pine.BSF.4.21.0107101540140.94227-100000@megazone23.bigpanda.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On 6 Jul 2001, Eric Chacon wrote:

> I have a file with the following contents:
>
> 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();
>
> When I run the 'UPDATE update_flag SET content=current_timestamp' in
> the SQL window (pgaccess), it works.
>
> When I type
> psql -f udt jags_content
>
> I get an error...
>
> DROP
> CREATE
> 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"
>
> What obvious thing am I missing?

RTFM? ;)
Seriously, If you're making a plpgsql language function, you're going to
need a begin and end. Also, if you want it to return text, you need to
make it return something.
The other option is to make it an sql function and add a select after the
update for the return value.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2001-07-10 23:10:24 Re: Grab data WHERE table.ID NOT LIKE otherTable.ID
Previous Message Chad R. Larson 2001-07-10 22:50:13 Re: NULL values