Received: from hermes.in.netwave.cc ([209.61.14.193]) by hub.org (8.8.8/8.7.5) with ESMTP id NAA01450 for ; Mon, 27 Jul 1998 13:23:56 -0400 (EDT) Received: from netwavelink.com ([192.168.1.111]) by hermes.in.netwave.cc (8.8.7/8.8.7) with ESMTP id NAA08863 for ; Mon, 27 Jul 1998 13:25:16 -0400 Message-ID: <35BCB7D1.A926B9C@netwavelink.com> Date: Mon, 27 Jul 1998 13:24:33 -0400 From: Tod Hagan Organization: Netwave X-Mailer: Mozilla 4.05 [en] (Win95; I) MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: Can Postgres functions be used as stored procedures? Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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