X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.224.193]) by svr1.postgresql.org (Postfix) with ESMTP id 9351630E7C3 for ; Thu, 12 Jun 2003 11:50:39 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr1.postgresql.org [64.117.224.193]) (amavisd-new, port 10024) with ESMTP id 56128-01 for ; Thu, 12 Jun 2003 08:50:29 -0300 (ADT) Received: from zenon.apartia.com (ATuileries-107-2-1-69.w217-128.abo.wanadoo.fr [217.128.120.69]) by svr1.postgresql.org (Postfix) with ESMTP id E05DF30E7B7 for ; Thu, 12 Jun 2003 08:50:28 -0300 (ADT) Received: from argos (argos.apartia.fr [10.0.2.105]) by zenon.apartia.com (Postfix) with ESMTP id DEB9A9A53D; Thu, 12 Jun 2003 13:50:28 +0200 (CEST) Received: by argos (Postfix, from userid 1018) id 69012DC4B; Thu, 12 Jun 2003 13:50:27 +0200 (CEST) Date: Thu, 12 Jun 2003 13:50:27 +0200 From: David Pradier To: Christoph Haller Cc: pgsql-sql@postgresql.org Subject: Re: How to make a IN without a table... ? Message-ID: <20030612115027.GB680@apartia.fr> Mail-Followup-To: Christoph Haller , pgsql-sql@postgresql.org References: <3EE8610A.EBE8B77@rodos.fzk.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3EE8610A.EBE8B77@rodos.fzk.de> User-Agent: Mutt/1.5.4i X-Archive-Number: 200306/101 X-Sequence-Number: 13859 On Thu, Jun 12, 2003 at 01:16:27PM +0200, Christoph Haller wrote: > > > > i ran today in a problem when doing some (i mean too much for me) > advanced sql... > > > > What i want to do is something like this: > > > > SELECT > > my_var1, > > my_var2, > > my_function(my_var1, my_var2) > > FROM ( > > SELECT > > '1', > > '2', > > '3', > > '4' > > ) AS my_var1_values, > > ( > > SELECT > > '1', > > '2', > > '3', > > '4' > > ) AS my_var2_values > > > > In short, i want to calculate the result of the function my_function > for > > some values of my_var1, cross by some values of my_var2. > > These values are not taken in a table, but put in directly. > > They are a lot, so i would prefer not to write the whole thing, line > > after line. (Let's say 10 values for the first, and 40 for the second > => > > 400 lines of code to maintain...) > > > > I really don't see how to do this :-/ > > > What about using a TEMP TABLE? I avoid as hell to use temporary tables. This is part of a complex database, with more than 250 different tables. So i don't even want to think about adding temporary tables, brrr ! > And COPY FROM STDIN offers a real fast way to populate. > BTW, why using SQL at all? Couldn't perl do the job much easier? I guess i wasn't clear enough. "my_function" here is a function which calculate some results about some datas from the database. Example : a function which would calculate the sum of the money (which would be stored in the database by movement, ie amount + date + cause + account) spent by user my_var1 during period my_var2. So no, perl can't do this. Regards, David -- dpradier@apartia.fr 01.46.47.21.33