From: | Raymond O'Donnell <rod(at)iol(dot)ie> |
---|---|
To: | Mike Christensen <mike(at)kitchenpc(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: PERFORM statement |
Date: | 2013-07-09 10:20:46 |
Message-ID: | 51DBE3FE.7060309@iol.ie |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 09/07/2013 05:20, Mike Christensen wrote:
> I was reading about Postgres stored procs in the FAQ:
>
> https://wiki.postgresql.org/wiki/FAQ#Does_PostgreSQL_have_stored_procedures.3F
>
> It claims that an alternative syntax to:
>
> SELECT theNameOfTheFunction(arg1, arg2);
>
> Is:
>
> PERFORM theNameOfTheFunction(arg1, arg2);
>
> However, when I try the following:
>
> CREATE TABLE app_for_leave
> (
> sno integer NOT NULL,
> eid integer,
> ename varchar(20),
> sd date,
> ed date,
> sid integer,
> status boolean DEFAULT false,
> CONSTRAINT pk_snoa PRIMARY KEY (sno)
> );
>
> CREATE FUNCTION MyInsert(_sno integer, _eid integer, _sd date, _ed date,
> _sid integer, _status boolean)
> RETURNS void AS
> $BODY$
> BEGIN
> INSERT INTO app_for_leave(sno, eid, sd, ed, sid, status)
> VALUES(_sno, _eid, _sd, _ed, _sid, _status);
> END;
> $BODY$
> LANGUAGE 'plpgsql' VOLATILE
> COST 100;
>
> PERFORM MyInsert(1,101,'2013-04-04','2013-04-04',2,'f' );
>
> I get the error:
>
> ERROR: syntax error at or near "PERFORM"
> SQL state: 42601
> Character: 1
PERFORM only works inside a pl/pgsql function. You use it when you want
to discard the result of a SELECT. So, for example, instead of this -
select foo from bar ...
- you would do this:
perform foo from bar ...
If you need the result, you would use SELECT INTO <variable>.
Ray.
--
Raymond O'Donnell :: Galway :: Ireland
rod(at)iol(dot)ie
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian.Vondendriesch | 2013-07-09 11:28:32 | Re: My question about autonomous transaction |
Previous Message | 高健 | 2013-07-09 09:29:21 | My question about autonomous transaction |