X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id A4EA1D1B3C6 for ; Thu, 20 May 2004 12:03:03 -0300 (ADT) 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 78648-07 for ; Thu, 20 May 2004 12:02:42 -0300 (ADT) Received: from megazone.bigpanda.com (megazone.bigpanda.com [64.147.171.210]) by svr1.postgresql.org (Postfix) with ESMTP id F2354D1B20F for ; Thu, 20 May 2004 12:01:53 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id A897B35AA2; Thu, 20 May 2004 08:01:52 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id A6DF235A7A; Thu, 20 May 2004 08:01:52 -0700 (PDT) Date: Thu, 20 May 2004 08:01:52 -0700 (PDT) From: Stephan Szabo To: Andreas Cc: Andrei Bintintan , pgsql-sql@postgresql.org Subject: Re: where to start with this procedure ? In-Reply-To: <40ACC4CA.4080406@gmx.net> Message-ID: <20040520075846.W14089@megazone.bigpanda.com> References: <40ABFCDE.8020601@gmx.net> <00bb01c43e3a$7d33f980$0b00a8c0@forge> <40ACC4CA.4080406@gmx.net> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200405/177 X-Sequence-Number: 17891 On Thu, 20 May 2004, Andreas wrote: > > Hi Andrei, > > > >Use the Offset and Limit in the SQL query. > >[...] > >SELECT select_list > > FROM table_expression > > WHERE condition > > LIMIT 50 > > OFFSET 10000 > > > >This query will return 50 elements starting with the 10000 elements... so > >the elemenst from 10000 to 10050. > > > > > > That isn't the issue since I only need a specific few of the lines at all. > I need a dynamic WHERE clause. > > It's more like this : > SELECT customer_id, and, some, more, fields > FROM table1 > JOIN table2 > JOIN table3 > .... > > This results in the "huge" set. > On the Access-form I only need the orders, or contact history for 1 > customer. > > As of now I only know 2 ways to solve this. > 1) Load all the tables over the net into Access and let the JOIN run > locally. That way I can filter dynamically by adding a WHERE > customer_id = x to the select above. Why not add the where clause to the select that goes to the server? In any case, you can do a function that does the select with a condition fairly easily with a set returning function in recent versions I think. Make a composite type with the return fields (create type as (...)) then make an sql function that takes an integer returns setof that selects from table1 join table2 ... where customer_id = $1.