pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tod Hagan <todh@netwavelink.com>
To: pgsql-sql@postgresql.org
Subject: Can Postgres functions be used as stored procedures?
Date: Mon, 27 Jul 1998 13:24:33 -0400
Message-ID: <35BCB7D1.A926B9C@netwavelink.com> (raw)

All the examples in the documentation of user-defined sql functions
return a single result. It is possible to use the 'setof' keyword to
define a function that (for example) executes a query and returns all
the records?

Below is an example of my attempt to make this work. While the function
returns the proper number of rows, it's returning a numeric value
instead of the record for each row. When 'select * from bar' is executed
directly from psql it returns the proper records from the table -- is
there any way I can encapsulate this behavior in a function?

	create function foo () returns setof bar
	        as 'select * from bar'
	        language 'sql';

	=>select foo() as foobar;
	   foobar
	---------
	135895376
	135895376
	135895376
	135895376
	135895376
	135895376
	135895376
	135895376
	135895376
	135895376
	135895376
	(11 rows)

-- 
Tod Hagan                                              On assignment at:
Bondcliff Internet Group                                   NetWave, Inc.
tod@bondcliff.com                                   todh@netwavelink.com



Message-ID: <35BCB7D1.A926B9C@netwavelink.com>
Permalink:  ../35BCB7D1.A926B9C@netwavelink.com/
Also on:    postgresql.org/message-id/35BCB7D1.A926B9C@netwavelink.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: todh@netwavelink.com
  Subject: Re: Can Postgres functions be used as stored procedures?
  In-Reply-To: <35BCB7D1.A926B9C@netwavelink.com>
  References: <35BCB7D1.A926B9C@netwavelink.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox