From: | Asche <asche(dot)public(at)mac(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Cc: | Hendra <manusiatidakbiasa(at)gmail(dot)com> |
Subject: | Re: Hi there, new here and have question |
Date: | 2008-07-08 17:04:16 |
Message-ID: | 25497368-261A-4C0A-9BAB-E1E8ED7E82E3@mac.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi Hendra,
> create function listofemployeebasedondepartment(id_dept int) $$
> declare
> resultset ??;
> begin
> select * into resultset from employee where id_dept = id_dept;
> return resultset;
> end
> $$ language 'plpgsql';
>
> I believe you get what I want
> But I just couldn't finish the code since I miss something
> I manage to find 'setof' but have no idea on how to use it
>
> Any suggestion everyone?
>
Try something like this:
CREATE OR REPLACE FUNCTION listofemployeebasedondepartment(id_dept int)
RETURNS SETOF employee AS
$BODY$
BEGIN
RETURN QUERY
SELECT
*
FROM
employee
WHERE
id_dept = _id_dept;
RETURN;
END;
$BODY$
LANGUAGE 'plpgsql';
Jan
From | Date | Subject | |
---|---|---|---|
Next Message | Asche | 2008-07-08 17:08:13 | Re: Hi there, new here and have question |
Previous Message | gabrielle | 2008-07-08 16:57:41 | Sign up for PDXPUG PgDay! July 20, 2008 |