X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 38A7B329D14 for ; Mon, 27 Sep 2004 01:34:33 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 46286-08 for ; Mon, 27 Sep 2004 00:34:26 +0000 (GMT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id 0280C329E39 for ; Mon, 27 Sep 2004 01:34:28 +0100 (BST) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id 526AF3547D; Sun, 26 Sep 2004 17:34:29 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 50F4D3545C; Sun, 26 Sep 2004 17:34:29 -0700 (PDT) Date: Sun, 26 Sep 2004 17:34:29 -0700 (PDT) From: Stephan Szabo To: Michael Snodgrass Cc: pgsql-sql@postgresql.org Subject: Re: Problem with functions In-Reply-To: <20040921013645.2203.qmail@web50804.mail.yahoo.com> Message-ID: <20040926172208.C46859@megazone.bigpanda.com> References: <20040921013645.2203.qmail@web50804.mail.yahoo.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/234 X-Sequence-Number: 19080 On Mon, 20 Sep 2004, Michael Snodgrass wrote: > I been trying to create several different functions > that mimic several stored procedures in MSSQL. > The SQL works fine in an interactive SQL, but fails > miserably when I try to run/execute a function created > using that same SQL. > I have been searching web sites and reading what I > find but I have not anything on functions that speaks > about the issue I'm having. > > I'm hoping maybe you can provide some input on how to > get these functions to work. I am including one of my > functions as sample. > > Here's the function: > CREATE OR REPLACE FUNCTION "public"."getappts" (text, > date, date) > RETURNS SETOF "public"."calendar" AS' > SELECT * > FROM calendar > WHERE > event_date BETWEEN $2 AND $3 > AND agent_number IN > ( SELECT agent_number FROM agents > WHERE rel30a = $1 OR > agent_number = $1 ) > ORDER BY event_start_time; > 'LANGUAGE 'plpgsql' VOLATILE CALLED ON NULL INPUT > SECURITY INVOKER; That's not the syntax for plpgsql set returning functions. I think however, you'd likely be able to make it work by using LANGUAGE 'sql'. If you want more information, there's the set returning function guide on techdocs: http://techdocs.postgresql.org/guides/SetReturningFunctions and a General Bits article at http://www.varlena.com/varlena/GeneralBits/26.html