Re: [SQL] Using Temporary Tables in postgres functions

2007-01-26 Thread Tom Lane
Mario Splivalo <[EMAIL PROTECTED]> writes: > On Thu, 2007-01-25 at 11:09 -0500, Tom Lane wrote: >> I believe the problem is that for a SQL function we parse the whole >> function body before executing any of it. So you'd need to split this >> into two separate functions. > Having two function com

Re: [SQL] Using Temporary Tables in postgres functions

2007-01-26 Thread Mario Splivalo
On Thu, 2007-01-25 at 11:09 -0500, Tom Lane wrote: > Mario Splivalo <[EMAIL PROTECTED]> writes: > > Am I doing something wrong here, or there is no way of using temporary > > tables within 'sql' written functions? > > I believe the problem is that for a SQL function we parse the whole > function b

Re: [SQL] Using Temporary Tables in postgres functions

2007-01-26 Thread Mario Splivalo
On Thu, 2007-01-25 at 11:00 -0500, Andrew Sullivan wrote: > On Thu, Jan 25, 2007 at 03:39:14PM +0100, Mario Splivalo wrote: > > When I try to use TEMPORARY TABLE within postgres functions (using 'sql' > > as a function language), I can't because postgres can't find that > > temporary table. Conside

Re: [SQL] Using Temporary Tables in postgres functions

2007-01-26 Thread Mario Splivalo
On Thu, 2007-01-25 at 08:03 -0800, Stephan Szabo wrote: > On Thu, 25 Jan 2007, Mario Splivalo wrote: > > > When I try to use TEMPORARY TABLE within postgres functions (using 'sql' > > as a function language), I can't because postgres can't find that > > temporary table. Consider this example: > >

Re: [SQL] Using Temporary Tables in postgres functions

2007-01-25 Thread Tom Lane
Mario Splivalo <[EMAIL PROTECTED]> writes: > Am I doing something wrong here, or there is no way of using temporary > tables within 'sql' written functions? I believe the problem is that for a SQL function we parse the whole function body before executing any of it. So you'd need to split this in

Re: [SQL] Using Temporary Tables in postgres functions

2007-01-25 Thread Stephan Szabo
On Thu, 25 Jan 2007, Mario Splivalo wrote: > When I try to use TEMPORARY TABLE within postgres functions (using 'sql' > as a function language), I can't because postgres can't find that > temporary table. Consider this example: > > CREATE FUNCTION func1() RETURNS SETOF v_messages_full AS $BODY$ >

Re: [SQL] Using Temporary Tables in postgres functions

2007-01-25 Thread Andrew Sullivan
On Thu, Jan 25, 2007 at 03:39:14PM +0100, Mario Splivalo wrote: > When I try to use TEMPORARY TABLE within postgres functions (using 'sql' > as a function language), I can't because postgres can't find that > temporary table. Consider this example: You need to build the temp table and EXECUTE the