Stored Procedure Assistance - Mailing list pgsql-general

From Bradley J. Bartram
Subject Stored Procedure Assistance
Date
Msg-id 200307081255.00649.bbartram@dyrectmedia.com
Whole thread Raw
Responses Re: Stored Procedure Assistance  (Alvaro Herrera <alvherre@dcc.uchile.cl>)
Re: Stored Procedure Assistance  (Michael Pohl <pgsql@newtopia.com>)
Re: Stored Procedure Assistance  (Richard Huxton <dev@archonet.com>)
List pgsql-general
I'm relatively new to stored procedures and I've run into a situation that is
above my current level of ability and I can't seem to find any examples of
how to go about it.

Here is the run down of what I need to do, if someone could either give me an
exmaple or even a nice repository of information on how to do this, I would
be quite grateful.

I'm looking at a series of queries, all simple selects, that are run to
produce a final result set.  Right now they are coded in php and there are
some techniques used to construct the queries that I'm trying to duplicate on
the backend.

The first query is simple:

SELECT a FROM table_a WHERE column_a = b

This will return a single row.  The next query takes that derived value and
does a simliar select that returns multiple rows.

SELECT c FROM table_b WHERE column_b = a

The next query has some logic in php that constructs it.  Basically if c > 0
than the results of query 2 are setup as ORs in the WHERE clause.

SELECT d FROM table_c WHERE column_c = c1 OR column_c = c2, etc.

The first two queries are not a problem, but how can I take the array of
results from query 2 and put them into query 3?

Thanks in advance.

brad
--
Bradley J. Bartram


pgsql-general by date:

Previous
From: "Maksim Likharev"
Date:
Subject: Re: PG crash on simple query, story continues
Next
From: "Maksim Likharev"
Date:
Subject: Re: PG crash on simple query, story continues