From: Pierre-Frédéric Caillaud <lists@boutiquenumerique.com>
To: Richard Rowell <richard@bowmansystems.com>
To: pgsql-sql@postgresql.org
Subject: Re: Recursive SETOF function
Date: Tue, 23 Nov 2004 00:19:17 +0100
Message-ID: <opshv22fo2cq72hf@musicbox> (raw)
In-Reply-To: <1101151552.18145.86.camel@richard>
References: <1101136693.18148.66.camel@richard>
<b918cf3d041122085437cde2f1@mail.gmail.com>
<b918cf3d04112208564c5fb783@mail.gmail.com>
<1101151552.18145.86.camel@richard>
> SELECT INTO cid count(*) FROM providers WHERE uid =child_provider;
Hey, hey.
Better :
SELECT blablah FROM providers WHERE uid = child_provider LIMIT 1;
IF NOT FOUND THEN exit with error ELSE do your stuff
Why scan more than 1 row when you just need existence ?
Or :
SELECT INTO cid parent_id FROM providers WHERE uid=cid;
WHILE FOUND
RETURN NEXT cid;
SELECT INTO cid parent_id FROM providers WHERE uid=cid;
END;
Not sure about the While syntax but you get the idea.
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: lists@boutiquenumerique.com, richard@bowmansystems.com
Subject: Re: Recursive SETOF function
In-Reply-To: <opshv22fo2cq72hf@musicbox>
* 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