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 1AF1E329E70 for ; Tue, 21 Sep 2004 02:37:04 +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 89703-07 for ; Tue, 21 Sep 2004 01:36:42 +0000 (GMT) Received: from web50804.mail.yahoo.com (web50804.mail.yahoo.com [206.190.38.113]) by svr1.postgresql.org (Postfix) with SMTP id 99D99329E64 for ; Tue, 21 Sep 2004 02:36:44 +0100 (BST) Message-ID: <20040921013645.2203.qmail@web50804.mail.yahoo.com> Received: from [24.0.196.132] by web50804.mail.yahoo.com via HTTP; Mon, 20 Sep 2004 18:36:45 PDT Date: Mon, 20 Sep 2004 18:36:45 -0700 (PDT) From: Michael Snodgrass Subject: Problem with functions To: pgsql-sql@postgresql.org 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/227 X-Sequence-Number: 19073 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; Yes, I need to return multiple rows in the result set. The two tables have the 'agent_number' column in common, ie it is really a foreign key. But it is not set up that way, it's not my database and I can not change it. __________________________________ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! http://promotions.yahoo.com/new_mail