X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id D757AD1B4E4 for ; Tue, 16 Dec 2003 19:00:37 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 89029-06 for ; Tue, 16 Dec 2003 15:00:07 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 14073D1B8F5 for ; Tue, 16 Dec 2003 15:00:06 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id hBGJ05U6015224 for ; Tue, 16 Dec 2003 19:00:05 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id hBGItOl7007669 for pgsql-sql@postgresql.org; Tue, 16 Dec 2003 18:55:24 GMT From: "Jonas Lindholm" X-Newsgroups: comp.databases.postgresql.sql Subject: Problem with functions. Date: Tue, 16 Dec 2003 13:55:24 -0500 Organization: OM Technology Lines: 77 Message-ID: X-Complaints-To: usenet@news.hub.org X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 To: pgsql-sql@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/149 X-Sequence-Number: 16315 Hi, I'n trying to create a function with two input values and returning a SETOF. When I only have one input value everything is working ok. If I instead create the same function with two input values the query fail with: ERROR: a column definition list is required for functions returning "record" The two functions are returning exactly the same type of data. This is the definition of the function with one input value that works ok: CREATE FUNCTION getlosts (timestamp) RETURNS SETOF userlog AS ' DECLARE beg ALIAS FOR $1; rec RECORD; BEGIN FOR rec IN SELECT * FROM userlog WHERE login > beg LOOP RETURN NEXT rec; END LOOP; RETURN; END; ' LANGUAGE 'plpgsql'; This is the definition of the function that fail: (note that I only added the secondary timestamp used to limit the upper value of the select) CREATE FUNCTION getlosts (timestamp, timestamp) RETURNS SETOF userlog AS ' DECLARE beg ALIAS FOR $1; ending ALIAS FOR $2; rec RECORD; BEGIN FOR rec IN SELECT * FROM userlog WHERE login > beg AND login < ending LOOP RETURN NEXT rec; END LOOP; RETURN; END; ' LANGUAGE 'plpgsql'; This is the definition of table userlog: Table "public.userlog" Column | Type | Modifiers ----------+--------------------------+----------- login | timestamp with time zone | logout | timestamp with time zone | reason | character varying(20) | source | character varying(32) | username | character varying(64) | gw | character varying(32) | ident | character varying(64) | id | integer | I'm running Postgres version 7.4. Thanks /Jonas L.