Re: [GENERAL] plpgsql return select from multiple tables

2008-09-11 Thread Artis Caune
On Wed, Sep 10, 2008 at 5:56 PM, Alvaro Herrera <[EMAIL PROTECTED]> wrote: > Ah, right, you only forgot to mention that other 99% of the > requirements. :) > What's wrong with your first example? It works, but those type casts "TRUE::BOOLEAN AS forwards" and selects with "AS (email VARCHAR, backe

Re: [GENERAL] plpgsql return select from multiple tables

2008-09-11 Thread Artis Caune
On Wed, Sep 10, 2008 at 5:43 PM, Filip Rembiałkowski <[EMAIL PROTECTED]> wrote: > nothing wrong here but this can also be rewritten to pure SQL function > (can be few percent faster and optimizable by planner) > > CREATE OR REPLACE FUNCTION get_user_data( INT ) > RETURNS SETOF RECORD AS $$ > SELECT

Re: [GENERAL] plpgsql return select from multiple tables

2008-09-10 Thread Alvaro Herrera
Artis Caune escribió: > Ops, forget to mention that this function is not so simple and use > some plpgsql features. Ah, right, you only forgot to mention that other 99% of the requirements. What's wrong with your first example? -- Alvaro Herrerahttp://www.Comman

Re: [GENERAL] plpgsql return select from multiple tables

2008-09-10 Thread Filip Rembiałkowski
2008/9/10 Artis Caune <[EMAIL PROTECTED]>: > Hi, > > What is the correct way of writing plpgsql function which needs return > columns from multiple tables? > > e.x.: > SELECT email FROM emails WHERE id = 1 > SELECT backend FROM backends WHERE id = 1 > > I need plpgsql function return both email and

Re: [GENERAL] plpgsql return select from multiple tables

2008-09-10 Thread Artis Caune
On Wed, Sep 10, 2008 at 5:26 PM, Alvaro Herrera <[EMAIL PROTECTED]> wrote: > Hmm, maybe > > select email, backend from emails, backends where email.id = 1 and > backend.id = 1; > ? > > You don't need a plpgsql function for this ... Ops, forget to mention that this function is not so simple and use

Re: [GENERAL] plpgsql return select from multiple tables

2008-09-10 Thread Alvaro Herrera
Artis Caune escribió: > Hi, > > What is the correct way of writing plpgsql function which needs return > columns from multiple tables? > > e.x.: > SELECT email FROM emails WHERE id = 1 > SELECT backend FROM backends WHERE id = 1 > > I need plpgsql function return both email and backend in one li