title: Writing a Procedure in PostgreSQL 9.1
body: <p>I am trying to write a procedure (function) in Postgres 9.1 to just select all data from a view and return it (all columns) so our application can use it.  The intent is to have the application make a call to the procedure whenever it wants the data.  My problem is that I cannot seem to get the syntax right to have it return any data.  I have written procedures in MySQL, SQL Server and Oracle but never in postgres and it is quite different.  Once it works is the best way to call it to just use select "function-name"?  Any help would be appreciated.</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION fg.get_flight_times()
  RETURNS setof record AS
  $BODY$
  declare times record;
  begin
  select * into times from fg.fn_dy_dest_dep_arr;
  return;
  end;
  $BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;
  ALTER FUNCTION fg.get_flight_times()
  OWNER TO jason;
  GRANT EXECUTE ON FUNCTION fg.get_flight_times() TO fltrakr;
  </code></pre>