X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.130]) by svr1.postgresql.org (Postfix) with ESMTP id 7F7B2D1B4F6 for ; Tue, 16 Sep 2003 20:05:03 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (neptune.hub.org [64.117.224.130]) (amavisd-new, port 10024) with ESMTP id 34873-02 for ; Tue, 16 Sep 2003 17:04:32 -0300 (ADT) Received: from smtp01.mrf.mail.rcn.net (smtp01.mrf.mail.rcn.net [207.172.4.60]) by svr1.postgresql.org (Postfix) with ESMTP id ADA11D1B4EB for ; Tue, 16 Sep 2003 17:04:29 -0300 (ADT) Received: from 216-15-127-80.c3-0.smr-ubr3.sbo-smr.ma.cable.rcn.com ([216.15.127.80] helo=moonbase.gungeralv.org) by smtp01.mrf.mail.rcn.net with esmtp (Exim 3.35 #4) id 19zM3r-0002Ff-00 for pgsql-admin@postgresql.org; Tue, 16 Sep 2003 16:04:31 -0400 Received: by moonbase.gungeralv.org (Postfix, from userid 500) id E6F73BC84; Tue, 16 Sep 2003 16:04:29 -0400 (EDT) Date: Tue, 16 Sep 2003 16:04:29 -0400 From: colin roald To: pgsql-admin@postgresql.org Subject: Re: SQL-Statement Message-ID: <20030916200429.GF3848@moonbase.hopto.org> References: <20030916115454.GA2115@intranet.etes.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030916115454.GA2115@intranet.etes.de> User-Agent: Mutt/1.4.1i X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200309/277 X-Sequence-Number: 10365 Quoth Markus Espenhain : > SELECT * FROM Hauptantrag WHERE (select datenfeldname from > datenexport) > (select datum_von from datenexport) AND (select > datenfeldname from datenexport) < (select datenexport.datum_bis from > datenexport) limit 10; If I understand you right, you want to compare some column from Hauptantrag to a range of values (datum_bis < 'some column' < datum_von), but you don't know what the column will be ahead of time. I believe this requires a dynamic sql statement, such as the plpython command 'execute': rv = plpy.execute( "SELECT * FROM Hauptantrag WHERE %s > %f AND %s < %f" % (colname, datum_von, datum_bis), 10) If you can, it's probably best to rework the logic of your code to avoid having to test unknown columns. -- colin | perfection is reached, not when there is no longer anything to add, roald | but when there is no longer anything to take away. (antoine de saint-exupery)