Return Query with simple function

From: dvanatta <dvanatta(at)yahoo(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Return Query with simple function
Date: 2008-02-24 00:33:01
Message-ID: 15659266.post@talk.nabble.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message ljb 2008-02-24 01:33:19 8.3 INSTALL: Why must I backup while my database is busy?
Previous Message Decibel! 2008-02-23 20:49:19 Re: unnesesary sorting after Merge Full Join