Re: [GENERAL] Cursors

2011-06-15 Thread Grzegorz Jaśkiewicz
Cursors only see the data that is the effect of the query. That output doesn't get updated. It would actually be pretty bad if that was the case. -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-ge

Re: [GENERAL] Cursors

2011-06-15 Thread Merlin Moncure
On Tue, Jun 14, 2011 at 11:54 PM, Andy Chambers wrote: > Hi, > > What happens to cursors when new data is added to a table after you > start iterating > over its rows? > > For example, given the following loop... > > for rule in select tc.sid, tc.s, td.rule, td.returns >                     from t

[GENERAL] Cursors

2011-06-14 Thread Andy Chambers
Hi, What happens to cursors when new data is added to a table after you start iterating over its rows? For example, given the following loop... for rule in select tc.sid, tc.s, td.rule, td.returns from tcell tc inner join tcelldef td on (tc.p = td.p)

Re: [GENERAL] Cursors WITH HOLD

2011-01-03 Thread pasman pasmański
Thanks for reply. I do some checking and some queries boost very well :) pasman -- Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general

Re: [GENERAL] Cursors WITH HOLD

2011-01-03 Thread Gurjeet Singh
2010/12/30 pasman pasmański > Hello. > > I use Postgres 8.4.5 via perl DBI. > And i try to use cursors WITH HOLD to materialize > often used queries. > > My question is how many cursors may be > declared per session and which memory setting s > to adjust for them ? > I believe there's no maximum

[GENERAL] Cursors WITH HOLD

2010-12-30 Thread pasman pasmański
Hello. I use Postgres 8.4.5 via perl DBI. And i try to use cursors WITH HOLD to materialize often used queries. My question is how many cursors may be declared per session and which memory setting s to adjust for them ? regards. pasman -- Sent via pgsql-general mailing list (pgsq

Re: [GENERAL] cursors from pl/pgsql

2010-04-07 Thread Marc Menem
hi guys, i solved this particular issue using the fetch syntax, so thanks for the tip. I agree with merlin that temp tables are a headache, also because i can't run the same function again before processing the output; I am not familiar with arrays, but it seems like a good solution for my proble

Re: [GENERAL] cursors from pl/pgsql

2010-04-07 Thread Merlin Moncure
On Tue, Apr 6, 2010 at 9:58 PM, Marc Menem wrote: > Hi all, > > I'm trying to use a cursor returned by a function from another function. But > I can't seem to get it working correctly. The error message is: >   ERROR:  cursor FOR loop must use a bound cursor variable > I am not sure how to bind it

Re: [GENERAL] cursors from pl/pgsql

2010-04-06 Thread Pavel Stehule
Hello 2010/4/7 Marc Menem : > Hi all, > > I'm trying to use a cursor returned by a function from another function. But > I can't seem to get it working correctly. The error message is: >   ERROR:  cursor FOR loop must use a bound cursor variable > I am not sure how to bind it; you can't do it now

[GENERAL] cursors from pl/pgsql

2010-04-06 Thread Marc Menem
Hi all, I'm trying to use a cursor returned by a function from another function. But I can't seem to get it working correctly. The error message is: ERROR: cursor FOR loop must use a bound cursor variable I am not sure how to bind it; my code is similar to this: create or replace function sto

Re: [GENERAL] cursors, temp tables, dynamic sql technique (was and is: looping over a small record set over and over in a function)

2009-06-21 Thread Craig Ringer
On Sun, 2009-06-21 at 22:11 +0200, Ivan Sergio Borgonovo wrote: > > > I think I really don't have a clear picture of how temp tables > > > really work. > > > They can be seen by concurrent transactions in the same session. > > > Eh? In this context, what do you mean by "session"? Did you mean > >

Re: [GENERAL] cursors, temp tables, dynamic sql technique (was and is: looping over a small record set over and over in a function)

2009-06-21 Thread Ivan Sergio Borgonovo
On Sun, 21 Jun 2009 21:43:16 +0800 Craig Ringer wrote: > On Sun, 2009-06-21 at 14:57 +0200, Ivan Sergio Borgonovo wrote: > > > I think everything could be summed up as: > > > > select into t myaggregate1(field) from dataset where condition1; > > if(t>10) then > > update dataset set field=myfu

Re: [GENERAL] cursors, temp tables, dynamic sql technique (was and is: looping over a small record set over and over in a function)

2009-06-21 Thread Craig Ringer
On Sun, 2009-06-21 at 14:57 +0200, Ivan Sergio Borgonovo wrote: > I think everything could be summed up as: > > select into t myaggregate1(field) from dataset where condition1; > if(t>10) then > update dataset set field=myfunc1(a,b,c) where condition1; > end if; > > select into t myaggregate2(

[GENERAL] cursors, temp tables, dynamic sql technique (was and is: looping over a small record set over and over in a function)

2009-06-21 Thread Ivan Sergio Borgonovo
On Sun, 21 Jun 2009 10:57:51 +0800 Craig Ringer wrote: > On Fri, 2009-06-19 at 20:23 +0200, Ivan Sergio Borgonovo wrote: > > > If I could easily load all the dataset into an array, loop > > through it and then just update the computed field it would be > > nice... but how? > > Are you sure you

Re: [GENERAL] cursors

2007-11-24 Thread Pavel Stehule
On 24/11/2007, Cesar Alvarez <[EMAIL PROTECTED]> wrote: > > Thanks, > what will be the syntax for that type of for? > DECLARE curs2 CURSOR FOR SELECT * FROM tenk1; c1 integer; c2 integer; BEGIN OPEN curs2; FETCH curs2 INTO c1,c2; WHILE found LOOP ... FETCH curs2 INTO c1,c2;

Re: [GENERAL] cursors

2007-11-24 Thread Cesar Alvarez
Thanks, what will be the syntax for that type of for? Pavel Stehule wrote: On 24/11/2007, Cesar Alvarez <[EMAIL PROTECTED]> wrote: Hello every one. im trying to make a Loop and i found in the manual this. FOR IN LOOP END LOOP Can i use cursor instead of the Query in the loop??

Re: [GENERAL] cursors

2007-11-24 Thread Pavel Stehule
On 24/11/2007, Cesar Alvarez <[EMAIL PROTECTED]> wrote: > > Hello every one. > im trying to make a Loop and i found in the manual this. > > FOR IN LOOP > > END LOOP > > Can i use cursor instead of the Query in the loop?? , > this es more legible than using the open/fetch/close of the

[GENERAL] cursors

2007-11-24 Thread Cesar Alvarez
Hello every one. im trying to make a Loop and i found in the manual this. FOR IN LOOP END LOOP Can i use cursor instead of the Query in the loop?? , this es more legible than using the open/fetch/close of the cursor. Regard Cesar Alvarez. begin:vcard fn:Cesar Alvarez n:;Cesar Alvarez titl

Re: [GENERAL] cursors in postgres

2007-03-29 Thread A . M .
On Mar 29, 2007, at 10:47 , Jasbinder Singh Bali wrote: Hi, I've written a function using cursors as follows: can anyone please comment on the text in red. -- CREATE OR REPLACE FUNCTION sp_insert_tbl_email_address(int4, text, text, text)

Re: [GENERAL] cursors in postgres

2007-03-29 Thread Jasbinder Singh Bali
Actually I'm doing a duplicate check My function accepts 4 parameters. If all four exist in a particular row then i should not be inserting that record again. so is INSERT INTO table(a,b,c) SELECT 'a','b','c' WHERE NOT EXISTS ( SELECT * FROM table WHERE (a,b,c) = ('a','b','c') ); going to solve m

Re: [GENERAL] cursors in postgres

2007-03-29 Thread A.M.
On Mar 29, 2007, at 10:47 , Jasbinder Singh Bali wrote: Hi, I've written a function using cursors as follows: can anyone please comment on the text in red. -- CREATE OR REPLACE FUNCTION sp_insert_tbl_email_address(int4, text, text, text)

Re: [GENERAL] cursors in postgres

2007-03-29 Thread Filip Rembiałkowski
2007/3/29, Jasbinder Singh Bali <[EMAIL PROTECTED]>: Hi, I've written a function using cursors as follows: can anyone please comment on the text in red. -- CREATE OR REPLACE FUNCTION sp_insert_tbl_email_address(int4, text, text, text) RETUR

[GENERAL] cursors in postgres

2007-03-29 Thread Jasbinder Singh Bali
Hi, I've written a function using cursors as follows: can anyone please comment on the text in red. -- CREATE OR REPLACE FUNCTION sp_insert_tbl_email_address(int4, text, text, text) RETURNS void AS $BODY$ DECLARE uid int4 ; src text;

Re: SPAM-LOW: [GENERAL] cursors and ASP page

2006-10-12 Thread William Penberthy
om: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of ANJANE Sent: Thursday, October 12, 2006 7:31 AM To: pgsql-general@postgresql.org Subject: SPAM-LOW: [GENERAL] cursors and ASP page I have a postgresql function defined as follows ... DECLARE int_userid ALIAS FOR $1; BEGIN OPEN $2 FOR SELEC

[GENERAL] cursors and ASP page

2006-10-12 Thread ANJANE
I have a postgresql function defined as follows ... DECLARE int_userid ALIAS FOR $1; BEGIN OPEN $2 FOR SELECT DISTINCT "users"."userloginid", "roles"."rolelike" FROM "roles" INNER JOIN "userpreferences" ON "roles"."roleid" = "userpreferences"."roleid" INNER JOIN "users" ON "use

Re: [GENERAL] cursors as table sources

2006-01-12 Thread Michael Fuhr
[Please copy the mailing list on replies. I'm forwarding your entire message to the list without comment so others can see it; I'll look at it when I get a chance.] On Thu, Jan 12, 2006 at 04:21:04PM +0200, Peter Filipov wrote: > It is the second case. > > I find cursors as good way to pass a re

Re: [GENERAL] cursors as table sources

2006-01-11 Thread Jim C. Nasby
On Wed, Jan 11, 2006 at 01:41:31PM -0500, Will Glynn wrote: > Michael Fuhr wrote: > > >... > > > >Is there a reason you'd want to use a cursor instead of, say, a view? > > > >Are you just curious or is there a problem you're trying to solve? > >If I've misunderstood what you're asking then please

Re: [GENERAL] cursors as table sources

2006-01-11 Thread Tom Lane
Will Glynn <[EMAIL PROTECTED]> writes: > Why can't I SELECT multi_column_function(t.a) FROM some_table t? You can. At least if you're running a recent release ;-) regression=# create function foo(int, out f1 int, out f2 int) as $$ regression$# begin regression$# f1 := $1 + 1; regression$# f2

Re: [GENERAL] cursors as table sources

2006-01-11 Thread Will Glynn
Michael Fuhr wrote: ... Is there a reason you'd want to use a cursor instead of, say, a view? Are you just curious or is there a problem you're trying to solve? If I've misunderstood what you're asking then please elaborate. I have previously thought this to be the most straightforward way

Re: [GENERAL] cursors as table sources

2006-01-11 Thread Tom Lane
Michael Fuhr <[EMAIL PROTECTED]> writes: > ... However, you could > write a set-returning function that takes a refcursor argument and > iterates through the cursor, returning each row, and use that > function in the FROM clause. Whether that's a good idea or not is > something I haven't given muc

Re: [GENERAL] cursors as table sources

2006-01-11 Thread Michael Fuhr
On Wed, Jan 11, 2006 at 04:11:18PM +0200, Peter Filipov wrote: > Is the idea to use cursors as table sources good? > Do you plan to implement it in the future and if you plan will it be soon? Do you mean the ability to use a cursor as one of the sources in the FROM clause? Something like the foll

[GENERAL] cursors as table sources

2006-01-11 Thread Peter Filipov
Hi, Is the idea to use cursors as table sources good? Do you plan to implement it in the future and if you plan will it be soon? Regards, Peter Filipov -- Using Opera's revolutionary e-mail client: http://www.opera.com/m2/ ---(end of broadcast)--

Re: [GENERAL] Cursors or Offset, Limit?

2005-11-16 Thread Andrew Sullivan
On Tue, Nov 15, 2005 at 01:44:32PM -0500, Jerry LeVan wrote: > > What are some of the tradeoffs between using a cursor and using the > limit/offset method of selecting rows to display? OFFSET actually has to scan all the preceding rows every time (plus to get it consistently, you need to do an OR

[GENERAL] Cursors or Offset, Limit?

2005-11-15 Thread Jerry LeVan
Hi, I am mucking around trying to build a gui'sh "table editor" for Postgresql. I am currently using a "held" cursor to move around the table, Since the "cursor" does not show table modification I am thinking about using the "limit" and "offset" attributes to select the rows to display. What

[GENERAL] cursors problem

2005-07-14 Thread Ковалевский Андрей
Hi! Is there any possibility to get the number of rows resulted by SELECT CURSOR? Best Regards, Andrei. ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate s

Re: [GENERAL] CURSORs and selects with parameters

2005-02-15 Thread Dan Sugalski
At 12:50 PM -0700 2/15/05, Michael Fuhr wrote: On Tue, Feb 15, 2005 at 02:32:56PM -0500, Dan Sugalski wrote: I've got some code that uses PQexecParams and does the equivalent of: DECLARE a_cursor CURSOR FOR SELECT foo, bar FROM baz WHERE field = $1 FETCH NEXT a_cursor but when I get to th

Re: [GENERAL] CURSORs and selects with parameters

2005-02-15 Thread Michael Fuhr
On Tue, Feb 15, 2005 at 02:32:56PM -0500, Dan Sugalski wrote: > > I've got some code that uses PQexecParams and does the equivalent of: > >DECLARE a_cursor CURSOR FOR SELECT foo, bar FROM baz WHERE field = $1 >FETCH NEXT a_cursor > > but when I get to the FETCH I'm getting back the error

[GENERAL] CURSORs and selects with parameters

2005-02-15 Thread Dan Sugalski
When using cursors through the libpq interface, do I need to be passing in the parameters when I'm FETCHing from them? I've got some code that uses PQexecParams and does the equivalent of: DECLARE a_cursor CURSOR FOR SELECT foo, bar FROM baz WHERE field = $1 FETCH NEXT a_cursor but when I g

Re: [GENERAL] Cursors and JDBC

2004-10-04 Thread Kris Jurka
On Mon, 4 Oct 2004, Wiebe de Jong wrote: > I am trying to implement cursors using JDBC connector version 7.1b5 > (postgresql-7.1b5.jar), but can't get it to work. Before saying anything else, I have to tell you to get off 7.1, especially a beta version of it. The first JDBC driver to have curs

[GENERAL] Cursors and JDBC

2004-10-04 Thread Wiebe de Jong
I am trying to implement cursors using JDBC connector version 7.1b5 (postgresql-7.1b5.jar), but can’t get it to work.   Could anybody suggest the proper way to do it, or even some source code? I am stuck with this version and can’t change it.   Thanks   Wiebe de Jong  

Re: [GENERAL] Cursors and PHP

2004-04-19 Thread scott.marlowe
I'm not sure why you're doing it the exact way you are, but you basically just call the same commands within a pg_query as you would on the psql command line to make it work: begin declare mycurs cursor as select * from table fetch 10 rollback / commit ---(end of bro

Re: [GENERAL] Cursors and Transactions, why?

2004-04-07 Thread Wes Palmer
On 4/6/04 11:09 PM, "Tom Lane" <[EMAIL PROTECTED]> wrote: > What "out of memory thing"? The tuplestore code is perfectly capable of > spilling to disk --- in fact the usual performance gripe against it has > to do with spilling too soon, because sort_mem is set too small. I tried doing a mass up

Re: [GENERAL] Cursors and Transactions, why?

2004-04-07 Thread Eric Ridge
On Apr 7, 2004, at 12:43 AM, Joe Conway wrote: Eric Ridge wrote: On Apr 6, 2004, at 11:54 AM, Jan Wieck wrote: And now you know why they are so good if you don't use all rows. This benefit I think goes away if you use Joe Conway's suggestion of WITH HOLD. Okay, so WITH HOLD is actually materiali

Re: [GENERAL] Cursors and Transactions, why?

2004-04-07 Thread Eric Ridge
On Apr 7, 2004, at 7:51 AM, Jan Wieck wrote: Eric Ridge wrote: On Apr 6, 2004, at 11:54 AM, Jan Wieck wrote: If the underlying query is for example a simple sequential scan, then the result set is not materialized but every future fetch operation will read directly from the base table. This woul

Re: [GENERAL] Cursors and Transactions, why?

2004-04-07 Thread Jan Wieck
Eric Ridge wrote: On Apr 6, 2004, at 11:54 AM, Jan Wieck wrote: If the underlying query is for example a simple sequential scan, then the result set is not materialized but every future fetch operation will read directly from the base table. This would obviously get screwed up if vacuum would th

Re: [GENERAL] Cursors and Transactions, why?

2004-04-06 Thread Joe Conway
Eric Ridge wrote: On Apr 6, 2004, at 11:54 AM, Jan Wieck wrote: And now you know why they are so good if you don't use all rows. This benefit I think goes away if you use Joe Conway's suggestion of WITH HOLD. Okay, so WITH HOLD is actually materializing the entire resultset (sequential scan or o

Re: [GENERAL] Cursors and Transactions, why?

2004-04-06 Thread wespvp
On 4/6/04 10:54 AM, "Jan Wieck" <[EMAIL PROTECTED]> wrote: >> Cursors seem as if they have some nice performance benefits (esp. if >> you're not using all rows found), but their usefulness drops >> considerably since you must leave a transaction open. > > And now you know why they are so good if

Re: [GENERAL] Cursors in SPI functions/procedures

2001-02-07 Thread Ian Lance Taylor
Jan Wieck <[EMAIL PROTECTED]> writes: > Ian Lance Taylor wrote: > > > > I have a patch which adds support for cursors in PL/pgSQL. If anybody > > is interested, I can provide that patch against either 7.0.3 or the > > current CVS sources. I have sent it to the maintainers, and they will > > con

Re: [GENERAL] Cursors in SPI functions/procedures

2001-02-07 Thread Jan Wieck
Ian Lance Taylor wrote: > Camm Maguire <[EMAIL PROTECTED]> writes: > > > Greetings! Just read that this functionality is planned for the > > future. Can 7.1 have cursors in pgsql functions, for example? > > No, it can't. > > I have a patch which adds support for cursors in PL/pgSQL. If anybody

Re: [GENERAL] Cursors in SPI functions/procedures

2001-02-01 Thread Ian Lance Taylor
Camm Maguire <[EMAIL PROTECTED]> writes: > Greetings! Just read that this functionality is planned for the > future. Can 7.1 have cursors in pgsql functions, for example? No, it can't. I have a patch which adds support for cursors in PL/pgSQL. If anybody is interested, I can provide that pat

[GENERAL] Cursors in SPI functions/procedures

2001-02-01 Thread Camm Maguire
Greetings! Just read that this functionality is planned for the future. Can 7.1 have cursors in pgsql functions, for example? Take care, -- Camm Maguire[EMAIL PROTECTED] == "The

Re: [GENERAL] Cursors and JDBC

2000-08-30 Thread Peter Mount
PostgreSQL JDBC: http://www.retep.org.uk/postgres/ Java PDF Generator: http://www.retep.org.uk/pdf/ - Original Message - From: "Travis Bauer" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Wednesday, August 30, 2000 2:52 PM Subject: [GENERAL] Cursors and JDBC > Doe

[GENERAL] Cursors and JDBC

2000-08-30 Thread Travis Bauer
Does the JDBC driver support the user of cursors in postgresql 7.0.2? Travis Bauer | CS Grad Student | IU |www.cs.indiana.edu/~trbauer