On Sun, 06 Jan 2008 02:47:17 -0500 Tom Lane <tgl@xxxxxxxxxxxxx> wrote: > Ivan Sergio Borgonovo <mail@xxxxxxxxxxxxxxx> writes: > > But when I switch to > > select into _BasketID1,_BasketID2 _BasketID1,_BasketID2 from > > testA(); nothing get back from testB(). > > I think you've forgotten that plpgsql variables will be substituted > for, wherever they appear. The above is just an extremely expensive > form of > _BasketID1 := _BasketID1; > _BasketID2 := _BasketID2; > ie, a big no-op. > The general rule of thumb is not to name plpgsql parameters or > variables the same as fields you'll need to reference in the > queries in the function. I've found a solution that is somehow elegant and unexpected: "aliasing" the function name. select a.field1, a.field2 into field1, field2 from testfunc() as a; The online documentation doesn't give postgresql the honour it deserves. Things like this can't be found even on voluminous books as "The Postgresql reference manual". If you're not a Postgres guru you may think that pg doesn't shine for anything other than things just "data paranoids" can appreciate but force you to live with "strangeness" like "ILIKE" and no syntactical sugar. It's plenty of syntactical sugar. It is just hidden in poetry like this: "Except for the INTO clause, the SELECT statement is the same as a normal SQL SELECT command and can use its full power." http://www.postgresql.org/docs/8.1/static/plpgsql-statements.html#PLPGSQL-SELECT-INTO -- Ivan Sergio Borgonovo http://www.webthatworks.it ---------------------------(end of broadcast)--------------------------- TIP 6: explain analyze is your friend