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

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

Reply via email to