pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kief Morris <k.morris@bitbull.com>
To: 'Peter Eisentraut' <peter_e@gmx.net>
Cc: 'pgsql-sql@postgresql.org' <pgsql-sql@postgresql.org>
Subject: RE: [SQL] Returning multiple rows in functions
Date: Mon, 6 Mar 2000 17:16:51 -0000
Message-ID: <30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net> (raw)


> > ... but it only returns the first matching row. Is there
> > a way to return all the matching rows?
> 
> No. Perhaps making a view would fit your application.

Looking over the docs for views, it doesn't seem like it
will work - I would need to create a new view for each
request, since the WHERE clause of the query changes 
depending on the user.

My query is actually a bit more complex than the example
I provided, I'm trying to do the following:

SELECT id FROM mytable WHERE
( value_id = 1  AND value < $1 + 1 AND value > $1 - 1 ) OR
( value_id = 2  AND value < $6 + 1 AND value > $6 - 1 ) OR
( value_id = 3  AND value < $7 + 1 AND value > $7 - 1 );

... and actually, I need to have about 10 of those clauses
in the WHERE clause of the statement. This is insanely
inefficient, there's got to be a smarter way to do this. 




view thread (3+ messages)

Message-ID: <30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net>
Permalink:  ../30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net/
Also on:    postgresql.org/message-id/30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: k.morris@bitbull.com, peter_e@gmx.net
  Subject: Re: [SQL] Returning multiple rows in functions
  In-Reply-To: <30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net>
  References: <30C64922AF42D311A96D00A0C91D0B107EB551@mailpost.syzygy.net>

* 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