Re: [GENERAL] plpgsql: returning multiple named columns from function

2005-08-23 Thread Tom Lane
John Lawler <[EMAIL PROTECTED]> writes: > Plus, the main part was to be able to have the columns (arbitrarily) > named as if they'd been selected from a table. I hope that there's > something about as easy as the example I cited from MS SQL. In existing releases you need to create a named compo

Re: [GENERAL] plpgsql: returning multiple named columns from function *simply*

2005-08-23 Thread Roger Hand
John Lawler wrote: > In MSSQL, I can write a stored procedure that > does something like this: > > CREATE PROCEDURE test( > @lookup char(50)) > WITH ENCRYPTION AS BEGIN > > -- ... a bunch of code to do some lookup, and then ... > > SELECT >@Result1 AS Result1, >@Result2 AS Result2, >

Re: [GENERAL] plpgsql: returning multiple named columns from function

2005-08-23 Thread Tony Caduto
you can do this with a function that returns a refcursor. (lookup refcursor in the docs) you would call it something like this select mycursorfunct(); fetch all from return_cursor; In this example I hardcode the name return cursor and then call both lines from a transaction. you could also r

Re: [GENERAL] plpgsql: returning multiple named columns from function

2005-08-23 Thread John Lawler
Joshua D. Drake wrote: perhaps even any existing column in a table. I think what you are looking for is SetOF functions. http://www.postgresql.org/docs/8.0/interactive/functions-srf.html Thanks for the response. The reference you indicated is talking about Set Returning Functions. I'm looki

Re: [GENERAL] plpgsql: returning multiple named columns from function

2005-08-23 Thread Joshua D. Drake
CREATE PROCEDURE test( @lookup char(50)) WITH ENCRYPTION AS BEGIN -- ... a bunch of code to do some lookup, and then ... SELECT @Result1 AS Result1, @Result2 AS Result2, @Result3 AS Result3, @Result4 AS Result4 END GO and then when I call this procedure, I get a result row (like it