pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephan Szabo <sszabo@megazone.bigpanda.com>
To: Andreas <maps.on@gmx.net>
Cc: Andrei Bintintan <klodoma@ar-sd.net>
Cc: pgsql-sql@postgresql.org
Subject: Re: where to start with this procedure ?
Date: Thu, 20 May 2004 08:01:52 -0700 (PDT)
Message-ID: <20040520075846.W14089@megazone.bigpanda.com> (raw)
In-Reply-To: <40ACC4CA.4080406@gmx.net>
References: <40ABFCDE.8020601@gmx.net>
	<00bb01c43e3a$7d33f980$0b00a8c0@forge>
	<40ACC4CA.4080406@gmx.net>

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 <name> as (...))
then make an sql function that takes an integer returns setof <name> that
selects from table1 join table2 ... where customer_id = $1.



view thread (4+ messages)

Message-ID: <20040520075846.W14089@megazone.bigpanda.com>
Permalink:  ../20040520075846.W14089@megazone.bigpanda.com/
Also on:    postgresql.org/message-id/20040520075846.W14089@megazone.bigpanda.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: sszabo@megazone.bigpanda.com, maps.on@gmx.net, klodoma@ar-sd.net
  Subject: Re: where to start with this procedure ?
  In-Reply-To: <20040520075846.W14089@megazone.bigpanda.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox