Stored Procedures and Return Type

From: Clinton Adams <clinton(at)vote-smart(dot)org>
To: pgsql-novice(at)postgresql(dot)org
Subject: Stored Procedures and Return Type
Date: 2002-02-28 00:48:13
Message-ID: 5.0.2.1.0.20020227173425.00ab8af0@mail.vote-smart.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Hello,

What would be the rtype for a function to return tuples selected over more
than one table? The closest I can find is setof but this rtype is for all
columns of only one table.

Example:

states
state_id integer
state_name varchar
state_abbreviation char(2)

districts
district_id integer
state_id integer
district_name varchar

CREATE OR REPLACE FUNCTION districts(varchar, varchar) RETURNS ???? AS '
SELECT state_name, districtname FROM states s, districts d
WHERE s.state_id = d.state_id AND s.state_name = $1 AND d.district_name = $2;
' LANGUAGE 'sql';

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2002-02-28 00:52:25 Re: v7.2-rpms for SuSE7.3
Previous Message Jochen Kaechelin 2002-02-28 00:19:01 phppgadmin