Re: PL/SQL question - Mailing list pgsql-general

From Stephan Szabo
Subject Re: PL/SQL question
Date
Msg-id 20040420194647.B40210@megazone.bigpanda.com
Whole thread Raw
In response to PL/SQL question  ("Froggy / Froggy Corp." <froggy@froggycorp.com>)
List pgsql-general
On Tue, 20 Apr 2004, Froggy / Froggy Corp. wrote:

>     I try to see if i can make a recursive function with a trigger set on
> INSERT and doing an insert under my trigger function.
>
>     So i wrote a test function :
>
>
> CREATE OR REPLACE FUNCTION testfunc() RETURNS SETOF RECORD AS '
> DECLARE
>     use_t RECORD;
> BEGIN
>
>     SELECT INTO use_t id_categorie FROM categorie ORDER BY id_categorie
> DESC;
>     IF use_t.id_categorie<>50 THEN
>         INSERT INTO categorie (nom) VALUES (''test'');
>     END IF;
>
>     RETURN NULL;
>
> END;
> 'LANGUAGE plpgsql;
>
>
> The problem is that i can't exec this function to test it, psql return
> the following error :
>
> "ERROR:  set-valued function called in context that cannot accept a set"

Record set returning functions aren't called as:
select foo();
 but instead as
select * from foo() AS foo(<columns>);

However, since you're not apparently actually returning a set of anything
in the function you may just want to change the return type.

pgsql-general by date:

Previous
From: jseymour@LinxNet.com (Jim Seymour)
Date:
Subject: Re: Basix for Data General / Basix for Sco Unix
Next
From: "Vincent Ladlad"
Date:
Subject: staggered query?