From: | Christian Schoenebeck <cschoene(at)stud(dot)hs-heilbronn(dot)de> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: CASE statement and SETOF values |
Date: | 2006-07-25 17:42:08 |
Message-ID: | 200607251942.08858.cschoene@stud.hs-heilbronn.de |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Am Dienstag, 25. Juli 2006 17:56 schrieben Sie:
> You could use a procedural language like plpgsql.
Ok, using the plpgsql approach I tried this:
CREATE FUNCTION my_function(int4) RETURNS SETOF int8 AS
$BODY$
DECLARE
myrow RECORD;
BEGIN
IF (some_condition) THEN
FOR myrow IN SELECT ... -- some select statement
LOOP
RETURN NEXT myrow."foocolumn";
END LOOP;
ELSE
FOR myrow IN SELECT ... -- some select statement
LOOP
RETURN NEXT myrow."foocolumn";
END LOOP;
END IF;
RETURN;
END;
$BODY$
LANGUAGE 'plpgsql' VOLATILE;
But creating this function fails, because it's "missing a LOOP" statement.
What am I missing?
CU
Christian
From | Date | Subject | |
---|---|---|---|
Next Message | Redefined Horizons | 2006-07-25 17:45:52 | Using currval() in an insert statement... |
Previous Message | Curtis Scheer | 2006-07-25 17:12:42 | Re: Splitting Timestamps |