Return Query with simple function - Mailing list pgsql-general

From dvanatta
Subject Return Query with simple function
Date
Msg-id 15659266.post@talk.nabble.com
Whole thread Raw
Responses Re: Return Query with simple function
List pgsql-general
I'm new to PostgreSQL, moving over from SQL Server and stored procs to
PostgreSQL 8.3 and it's functions and having some difficulty.  With SQL
Server I didn't have to define types and return those types from stored
procs which was convenient.  I came across Return Query but can't find much
info on how to use it.  I'm hoping Return Query will allow me to NOT have to
define types. I want to do the following but it doesn't work and I don't get
very helpful error info.  How should this function be written?  Do I have to
define a type and fill it?

CREATE OR REPLACE FUNCTION get_person(PersonId integer)
$BODY$
  BEGIN
    Return Query
    SELECT
    p.fname, j.title
    FROM   person p
         Inner join job j
        on p.personid = j.personid
    WHERE p.personid = PersonID;
  END;
$BODY$
  LANGUAGE 'plpgsql' VOLATILE
--
View this message in context: http://www.nabble.com/Return-Query-with-simple-function-tp15659266p15659266.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


pgsql-general by date:

Previous
From: Decibel!
Date:
Subject: Re: Approaches for Lookup values (codes) in OLTP application
Next
From: ljb
Date:
Subject: 8.3 INSTALL: Why must I backup while my database is busy?