Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJ21H-0005yX-K6 for pgsql-sql@arkaria.postgresql.org; Thu, 27 Feb 2014 14:33:03 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WJ21H-0007EI-4q for pgsql-sql@arkaria.postgresql.org; Thu, 27 Feb 2014 14:33:03 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJ21G-0007EC-Ds for pgsql-sql@postgresql.org; Thu, 27 Feb 2014 14:33:02 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJ21E-0006HA-Cg for pgsql-sql@postgresql.org; Thu, 27 Feb 2014 14:33:01 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id s1REWxhN030403; Thu, 27 Feb 2014 09:32:59 -0500 From: Tom Lane To: ALMA TAHIR cc: "pgsql-sql@postgresql.org" Subject: Re: Function Issue In-reply-to: <1393503792.47079.YahooMailNeo@web192706.mail.sg3.yahoo.com> References: <1393503792.47079.YahooMailNeo@web192706.mail.sg3.yahoo.com> Comments: In-reply-to ALMA TAHIR message dated "Thu, 27 Feb 2014 20:23:12 +0800" Date: Thu, 27 Feb 2014 09:32:59 -0500 Message-ID: <30402.1393511579@sss.pgh.pa.us> X-Pg-Spam-Score: -0.0 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-sql Precedence: bulk Sender: pgsql-sql-owner@postgresql.org ALMA TAHIR writes: > I want to open a ref cursor with select for update and then update > the records and get the ref cursor in response back in java. Your function has already sucked all the rows out of the cursor before it returns it, so it's not surprising that further reads from the cursor produce nothing. You could try rewinding the cursor (see MOVE) but I'm not sure that will help in this case, since the function has carefully ensured that none of the rows pass the cursor query's WHERE condition anymore. I think that since the cursor used SELECT FOR UPDATE, it will not return the updated rows even after rewinding. (I could be wrong though, so it's worth trying.) I think you need to rethink what you're doing. This seems like a fairly silly application design: why not do all the processing you need on these rows in one place? Or at the very least, don't use one cursor to serve two masters. Possibly you could have the function return the rows itself instead of passing back a refcursor. regards, tom lane -- Sent via pgsql-sql mailing list (pgsql-sql@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-sql