Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-25 Thread Craig Ringer
On 08/24/2012 10:31 PM, Tom Lane wrote: Craig Ringer writes: I didn't find a reasonable way to simply fetch a cursor into a (possibly temporary) table, like: INSERT INTO sometable FETCH ALL FROM somecursor; Why would you bother with a cursor, and not just INSERT ... SELECT using the original q

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-24 Thread Tom Lane
Craig Ringer writes: > I didn't find a reasonable way to simply fetch a cursor into a (possibly > temporary) table, like: > INSERT INTO sometable FETCH ALL FROM somecursor; Why would you bother with a cursor, and not just INSERT ... SELECT using the original query? Putting a cursor in between w

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-24 Thread Pavel Stehule
2012/8/24 Craig Ringer : > On 08/24/2012 12:34 PM, Pavel Stehule wrote: > >> you can't mix planned and unplanned statements together - think about >> stored plans every time > > > Thanks Pavel and Jeff. > > I can't say I fully understand the arguments, but I'll take it that > accepting cursors in C

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-24 Thread Craig Ringer
On 08/24/2012 12:34 PM, Pavel Stehule wrote: you can't mix planned and unplanned statements together - think about stored plans every time Thanks Pavel and Jeff. I can't say I fully understand the arguments, but I'll take it that accepting cursors in CTEs or subqueries wouldn't make sense. I

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-23 Thread Pavel Stehule
Hello 2012/8/24 Craig Ringer : > Hi all > > I've noticed that FETCH doesn't seem to be supported in subqueries or in > CTEs. > > Is there a specific reason for that, beyond "nobody's needed it and > implemented it"? I'm not complaining at all, merely curious. > > A toy example: > > DECLARE som

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-23 Thread Jeff Davis
On Fri, 2012-08-24 at 09:35 +0800, Craig Ringer wrote: > Hi all > > I've noticed that FETCH doesn't seem to be supported in subqueries or in > CTEs. > > Is there a specific reason for that, beyond "nobody's needed it and > implemented it"? I'm not complaining at all, merely curious. 1. Cursors