From: | "Alain Roger" <raf(dot)news(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | FOR ... IN |
Date: | 2006-11-06 19:39:21 |
Message-ID: | 75645bbb0611061139q73727900na9239de37c4e5a6a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi,
Before (in version 8.0.1), i did the following thing and it was working
well...now (in version 8.1.4) it seems that it does not work anymore...
problem is with FOR rec IN loop...
So how can i tell "FOR all RECORDS from select * from articles,
articletypes, department where ..." LOOP ... ?
thanks,
Al.
CREATE OR REPLACE FUNCTION "public"."SP_U_001" ("TypeOfArticle" varchar)
RETURNS SETOF "public"."active_articles" AS
$body$
DECLARE
TypeArt VARCHAR := $1;
rec RECORD;
res active_articles;
/**************************************/
BEGIN
FOR rec IN
select *
from articles, articletypes, department
where
articletypes.articletype_type = $1
AND articles.articletype_id = articletypes.articletype_id
AND articles.department_id = department.department_id
AND articles.validity_period_end > now()
LOOP
res.article_type := rec.articletypes.articletype_type;
res.article_author := rec.articles.author;
res.department_owner := rec.department.department_name;
res.department_picture := rec.department.department_picture;
res.article_title := rec.articles.title;
res.article_content := rec.articles.content;
res.date_creation := rec.articles.creation_date;
res.date_start := rec.articles.validity_period_start;
res.date_end := rec.articles.validity_period_end;
RETURN NEXT res;
END LOOP;
END;
$body$
LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT SECURITY INVOKER;
From | Date | Subject | |
---|---|---|---|
Next Message | Paul Ramsey | 2006-11-06 19:41:06 | Re: PostGIS Binary RPM for Red Hat Linux |
Previous Message | Sandeep Kumar Jakkaraju | 2006-11-06 19:36:48 | Re: PostGIS Binary RPM for Red Hat Linux |