How to return records from a function

From: "John Cavacas" <oogly(at)rogers(dot)com>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: How to return records from a function
Date: 2003-02-02 15:44:05
Message-ID: 000d01c2cad1$eb3a7e50$6401a8c0@spook
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello everyone.
I've spent the last few hours trying to come up with a function that
at the most basic returns the result of a SELECT * FROM <table>.

This is easy to do in something like MSSQL or Oracle. For example in
MSSQL i can do something like:

CREATE PROCEDURE proc_name AS

BEGIN
SELECT * FROM sometable
END

How do I do something like that with a Postgresql function/stored
procedure? All I really want to know is how to by using a function how
can I return the results of a SELECT * query!?

The end result of the query I need is more complicated, but I can't
even get something that easy to work. Are functions unable to return
result sets?? All of the examples i've seen always return a single
value, like an int. That doesn't do me any good.

I want to use a few stored procedures to create some faster processing
for some queries that involve 3-4 tables plus require some input
parameters, and return a result set.

Any help would be appreciated. I've just recently started using
PostgreSQL and I'm very impressed! I'm sure I'm jsut overlooking
something easy, but for the life of me i just can't figure it out.

Thanks,
John

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message jasiek 2003-02-02 15:52:41 Re: How to return records from a function
Previous Message Vic Cekvenich 2003-02-02 14:47:58 help: pgSQL docs and debug