Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 187659FB28B for ; Wed, 17 Jan 2007 20:51:41 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 59953-03 for ; Wed, 17 Jan 2007 20:50:41 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from a2s5.a2hosting.com (a2s5.a2hosting.com [209.124.50.10]) by postgresql.org (Postfix) with ESMTP id 101869FB2AC for ; Wed, 17 Jan 2007 20:50:46 -0400 (AST) Received: from adsl-150-239-12.tys.bellsouth.net ([72.150.239.12] helo=[192.168.1.12]) by a2s5.a2hosting.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.63) (envelope-from ) id 1H7LUK-000605-4A; Wed, 17 Jan 2007 19:50:44 -0500 In-Reply-To: <1364.62.66.218.59.1169073199.squirrel@mail.agile.dk> References: <1364.62.66.218.59.1169073199.squirrel@mail.agile.dk> Mime-Version: 1.0 (Apple Message framework v752.3) X-Priority: 3 (Normal) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <2AFADCD2-C72D-40FB-8B8E-D6FD023F2148@pgedit.com> Cc: pgsql-sql@postgresql.org Content-Transfer-Encoding: 7bit From: John DeSoi Subject: Re: Some help with functions-syntax Date: Wed, 17 Jan 2007 19:50:40 -0500 To: Jan Meyland Andersen X-Mailer: Apple Mail (2.752.3) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - a2s5.a2hosting.com X-AntiAbuse: Original Domain - postgresql.org X-AntiAbuse: Originator/Caller UID/GID - [0 0] / [47 12] X-AntiAbuse: Sender Address Domain - pgedit.com X-Source: X-Source-Args: X-Source-Dir: X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200701/73 X-Sequence-Number: 27225 Take a look at the documentation and examples again: http://www.postgresql.org/docs/8.2/interactive/plpgsql-control- structures.html#PLPGSQL-RECORDS-ITERATING There are two forms to iterate over the query: 1. FOR target IN query LOOP 2. FOR target IN EXECUTE text_expression LOOP In your code you have mixed the two together. You appear to be trying to concatenate a string on to the end of a query expression. My suggestion is to eliminate the string you created (_WHERECLAUSE) and add the proper conditions to the query expression you already have. On Jan 17, 2007, at 5:33 PM, Jan Meyland Andersen wrote: > I have some problem with writing a function. > > I have made this function which I can't get it to work. > > This is probaly a triviel question but i'm new to plsql, so this is a > showstopper for me. John DeSoi, Ph.D. http://pgedit.com/ Power Tools for PostgreSQL