[GENERAL] FETCH FORWARD 0 and cursor can only scan forward error

2013-09-04 Thread Trigve Siver
Hi, I'm on PostgreSQL 9.2.2 and trying to use no scroll cursor for some data fetch. But when moving cursor ahead one record and the fetching the actual record the error cursor can only scan forward is returned. I don't know if I'm doing something wrong but I don't think I'm going backward with

Re: [GENERAL] FETCH FORWARD 0 and cursor can only scan forward error

2013-09-04 Thread Giuseppe Broccolo
Hi Trigve, Il 04/09/2013 15:06, Trigve Siver ha scritto: Hi, I'm on PostgreSQL 9.2.2 and trying to use no scroll cursor for some data fetch. But when moving cursor ahead one record and the fetching the actual record the error cursor can only scan forward is returned. I don't know if I'm doing

Re: [GENERAL] FETCH FORWARD 0 and cursor can only scan forward error

2013-09-04 Thread Trigve Siver
From: Tom Lane t...@sss.pgh.pa.us To: Trigve Siver trig...@yahoo.com Cc: pgsql-general@postgresql.org pgsql-general@postgresql.org Sent: Wednesday, September 4, 2013 7:04 PM Subject: Re: [GENERAL] FETCH FORWARD 0 and cursor can only scan forward error T rigve Siver trig...@yahoo.com

Re: [GENERAL] FETCH FORWARD 0 and cursor can only scan forward error

2013-09-04 Thread Tom Lane
Trigve Siver trig...@yahoo.com writes: yes I know that when specifying FORWARD 0 that no move is done and actual record is returned. But my question is why it is forbidden by NO SCROLL? Because it's implemented as back up 1 row and re-fetch. regards, tom lane --

Re: [GENERAL] FETCH FORWARD 0 and cursor can only scan forward error

2013-09-04 Thread Trigve Siver
From: Giuseppe Broccolo giuseppe.brocc...@2ndquadrant.it To: pgsql-general@postgresql.org Sent: Wednesday, September 4, 2013 6:26 PM Subject: Re: [GENERAL] FETCH FORWARD 0 and  cursor can only scan forward error Hi Trigve, Il 04/09/2013 15:06, Trigve Siver

Re: [GENERAL] FETCH FORWARD 0 and cursor can only scan forward error

2013-09-04 Thread David Johnston
Trigve Siver wrote I want to iterate all records with cursor from beginning to end. This sample could be rewritten using FETCH FORWARD 1 ... without using MOVE but I'm interested with solution which throws error. Is you interest purely academic or is there some reason you were evaluating this

Re: [GENERAL] FETCH FORWARD 0 and cursor can only scan forward error

2013-09-04 Thread Trigve
David Johnston polobo at yahoo.com writes: Trigve Siver wrote I want to iterate all records with cursor from beginning to end. This sample could be rewritten using FETCH FORWARD 1 ... without using MOVE but I'm interested with solution which throws error. Is you interest purely

[GENERAL] fetch from cursor in pg_stats_activity and related SQL query

2012-11-20 Thread aasat
Hi, Is it possible to get information about SQL query for given session? The view pg_stats_activity shows only FETCH ALL IN unnamed portal X Thanks Regards aasat -- View this message in context:

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 ring...@ringerc.id.au 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 ...

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.

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-24 Thread Pavel Stehule
2012/8/24 Craig Ringer ring...@ringerc.id.au: 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

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-24 Thread Tom Lane
Craig Ringer ring...@ringerc.id.au 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

[GENERAL] FETCH in subqueries or CTEs

2012-08-23 Thread 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 somecursor CURSOR FOR SELECT

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 have

Re: [GENERAL] FETCH in subqueries or CTEs

2012-08-23 Thread Pavel Stehule
Hello 2012/8/24 Craig Ringer ring...@ringerc.id.au: 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:

[GENERAL] Fetch from cursor with indexed sorting

2012-03-15 Thread Andrey Chursin
Hello I have CURSOR for query SELECT a FROM table ORDER BY xyz, where table a is extremely large and xyz is hard-to-evaluate, but indexable expression(using gist). As far as I understand, on SELECT a FROM table ORDER BY xyz LIMIT X query postgres do not fetch entire index or table, but it uses

Re: [GENERAL] Fetch from cursor with indexed sorting

2012-03-15 Thread Tom Lane
Andrey Chursin an...@danasoft.ws writes: I need to create cursor, open it, fetch records one-by-one and aggregate. Then on some condition I stop fetching and return aggregated value. In fact in most cases my procedure scans a little part of table. But does postgres understand such usage of

[GENERAL] Fetch from refcursor and transactions

2011-12-23 Thread aasat
Hi, I have question about fetching data from refcursor, why this operation required to be inside transaction? for example with transaction begin; select * from foo(); fetch all from unnamed portal 1; commit; when I try this without transaction I get error select * from foo(); fetch all from

Re: [GENERAL] Fetch from refcursor and transactions

2011-12-23 Thread Adrian Klaver
On Friday, December 23, 2011 5:13:45 am aasat wrote: Hi, I have question about fetching data from refcursor, why this operation required to be inside transaction? for example with transaction begin; select * from foo(); fetch all from unnamed portal 1; commit; when I try this

[GENERAL] Fetch query which triggered a rule

2008-11-20 Thread Jonatan Evald Buus
Greetings, Is it possible to fetch the query which triggered a rule? I.e. suppose I create the following rule: CREATE RULE MyRule AS ON Select TO MyTable_Tbl DO INSTEAD process_query($sql); Where $sql represents the query which triggered the rule. Appreciate the input Cheers Jona

[GENERAL] Fetch for Update

2008-07-28 Thread Bob Pawley
I haven't been able to find much information on Fetch for Update. Does 8.3 support this command?? If so, could someone please point out my error in the following? Bob BEGIN SELECT count (p_id.pid.process_id) INTO Proccount FROM p_id.p_id WHERE process_id = new.process_id; Declare

Re: [GENERAL] Fetch for Update

2008-07-28 Thread justin
Bob Pawley wrote: I haven't been able to find much information on Fetch for Update. Does 8.3 support this command?? If so, could someone please point out my error in the following? Bob BEGIN SELECT count (p_id.pid.process_id) INTO Proccount FROM p_id.p_id WHERE process_id =

Re: [GENERAL] Fetch for Update

2008-07-28 Thread Christophe
On Jul 28, 2008, at 9:16 AM, Bob Pawley wrote: I haven't been able to find much information on Fetch for Update. Does 8.3 support this command?? Postgres doesn't have an explicit FETCH FOR UDPATE. You can either create the cursor with SELECT FOR UPDATE, or UPDATE the row in the cursor

[GENERAL] Fetch

2007-10-18 Thread Bob Pawley
When I fetch a row it returns a row number. Is there a method under the fetch command of either not returning the row number or of ignoring it after it is returned. begin work; Declare loop_set Cursor for Select one, two from loop_import order by loop_id ; fetch

[GENERAL] Fetch in select statement

2006-04-14 Thread Sam Thukral
Hello, Is it possible to fetch from a cursor and join the results with the out parameters from a function? Is it possible to do this in a prepared statement in ADO using ODBC? Sam Thukral

[GENERAL] Fetch statements

2005-12-16 Thread Carlos Benkendorf
Hi,I´m trying to discover some bad SQL statements in our environment but the logs are not helping too much... they say we´ve somevery badfetch statements butI don´t know how to discover the corresponding SELECT statement...How can I find them?Some example: 10.0.1.122(3821) 5072 2005-12-16

Re: [GENERAL] Fetch statements

2005-12-16 Thread Michael Fuhr
On Fri, Dec 16, 2005 at 06:28:03PM +, Carlos Benkendorf wrote: I´m trying to discover some bad SQL statements in our environment but the logs are not helping too much... they say we´ve some very bad fetch statements but I don´t know how to discover the corresponding SELECT statement...

Re: [GENERAL] Fetch statements

2005-12-16 Thread Carlos Benkendorf
Sorry, I would like to say "take longer than" with "bad" statements... but I´m only logging statements that take longer than 700 ms and DECLARE statements are not logged of course. I think the only way in my case is logging all statements... Am I right? Or is there another way?Thanks!

Re: [GENERAL] Fetch statements

2005-12-16 Thread Michael Fuhr
On Fri, Dec 16, 2005 at 08:49:32PM +, Carlos Benkendorf wrote: I would like to say take longer than with bad statements... but I´m only logging statements that take longer than 700 ms and DECLARE statements are not logged of course. I think the only way in my case is logging all