Received: from finch-post-10.mail.demon.net (finch-post-10.mail.demon.net [194.217.242.38]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f4JCYLA91943 for ; Sat, 19 May 2001 08:34:21 -0400 (EDT) (envelope-from dev@archonet.com) Received: from mwynhau.demon.co.uk ([193.237.186.96] helo=mainbox.archonet.com) by finch-post-10.mail.demon.net with esmtp (Exim 2.12 #1) id 1515w1-000MfX-0A; Sat, 19 May 2001 12:34:17 +0000 Received: from archonet.com (ibook.archonet.com [192.168.1.32]) by mainbox.archonet.com (Postfix) with ESMTP id ABB9A1345D; Sat, 19 May 2001 13:07:42 +0100 (BST) Message-ID: <3B0661ED.B43C0DC6@archonet.com> Date: Sat, 19 May 2001 13:07:08 +0100 From: Richard Huxton X-Mailer: Mozilla 4.7C-CCK-MCD {C-UDP; EBM-APPLE} (Macintosh; I; PPC) X-Accept-Language: en MIME-Version: 1.0 To: Bruno Boettcher Cc: pgsql-sql@postgresql.org Subject: Re: HELP: what's wrong with my PL/PSQL function?? References: <20010518112136.A468@erm1.u-strasbg.fr> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Archive-Number: 200105/206 X-Sequence-Number: 3023 Bruno Boettcher wrote: > > and i get an error: > ERROR: parser: parse error at or near "$1" > (BTW would be helpful if the thing could spit out also the line > number....) You can get syntax error line-numbers by editing the function in a text-file and \i file to import it. Otherwise, plpgsql's error reporting is a bit weak. > isolated the prob to this line: > FOR arow IN SELECT * FROM "jrlname" WHERE plus=sumup LOOP > in fact it doesn't seem to like the fact that i use a dynamic table > name?? > i remind vaguely that pl/psql had indeed this sort of problem... but > this was years ago.... is there any workaround? even using perl? Still there - plpgsql script is pre-compiled so there's no easy way around it. There is a new EXECUTE command available which takes a string and runs it as a query, but I don't think it'll help you here (could be wrong, check the archives there was a discussion about a similar problem some time ago IIRC). > The whole prog is a bookkeeping program... and i want it now really able > to work with several sets of tables.... without duplicating also the > functions i wrote associated to the tables.... You could use the EXECUTE system to generate one function for each table. See the auto-timestamp generator in Roberto Mello's plpgsql cookbook at http://techdocs.postgresql.org/ for an example. Otherwise tcl/perl scripting should help you since these aren't pre-compiled. Can't comment further since I don't use them. HTH - Richard Huxton