Re: Recursive SETOF function - Mailing list pgsql-sql

From Pierre-Frédéric Caillaud
Subject Re: Recursive SETOF function
Date
Msg-id opshv22fo2cq72hf@musicbox
Whole thread Raw
In response to Re: Recursive SETOF function  (Richard Rowell <richard@bowmansystems.com>)
List pgsql-sql
>     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
FROMproviders WHERE uid=cid;END;
 
Not sure about the While syntax but you get the idea.


pgsql-sql by date:

Previous
From: Richard Rowell
Date:
Subject: Re: [postgres] Re: Recursive SETOF function
Next
From: sreejith s
Date:
Subject: Image Insert Postgresql DB