Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJNIO-0002xA-9f for pgsql-sql@arkaria.postgresql.org; Fri, 28 Feb 2014 13:16:09 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1WJNIN-0005Yo-Lm for pgsql-sql@arkaria.postgresql.org; Fri, 28 Feb 2014 13:16:07 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJNIM-0005Yi-I4 for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 13:16:06 +0000 Received: from nm32.bullet.mail.ne1.yahoo.com ([98.138.229.25]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1WJNIJ-00057m-My for pgsql-sql@postgresql.org; Fri, 28 Feb 2014 13:16:05 +0000 Received: from [127.0.0.1] by nm32.bullet.mail.ne1.yahoo.com with NNFMP; 28 Feb 2014 13:16:01 -0000 Received: from [98.138.100.118] by nm32.bullet.mail.ne1.yahoo.com with NNFMP; 28 Feb 2014 13:13:11 -0000 Received: from [106.10.166.126] by tm109.bullet.mail.ne1.yahoo.com with NNFMP; 28 Feb 2014 13:13:10 -0000 Received: from [106.10.151.253] by tm15.bullet.mail.sg3.yahoo.com with NNFMP; 28 Feb 2014 13:13:10 -0000 Received: from [127.0.0.1] by omp1002.mail.sg3.yahoo.com with NNFMP; 28 Feb 2014 13:13:10 -0000 X-Yahoo-Newman-Property: ymail-4 X-Yahoo-Newman-Id: 376247.18338.bm@omp1002.mail.sg3.yahoo.com Received: (qmail 13707 invoked by uid 60001); 28 Feb 2014 13:13:10 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.in; s=s1024; t=1393593190; bh=KzObqkrNNPQsMtAfTsERTpqX66KYwTHQGvZ98T4yj6Q=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=W2satYub9ukbvQjOgRx71rS6n0909oxYFswJFVpOAAv2t2g0pXnHjCGhEbrcCWHn47wabwRfpMP+MDCNydOhbXPfvRwAMH33rlJ4LygineB8yTFmXqAKmMUsfbOL/3NqnzSx/k/usBaIK1cLXbDJmA1p+38d0qV1mOF9GibfmUc= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.co.in; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:Cc:In-Reply-To:MIME-Version:Content-Type; b=wmzLdyMmKSUwV+nJBwc5gyyYpmGOTuOSXAbwn0afsFsQ6VhunDLGjuLytSdqnPulCmtZEJxHn7h6q2AakQpq0Hw3ujKLLzrLxMLbqzwrcHc3hX6aAwCFP7mS++3FPnxhK/KectDqoUGGIFTDFzXM4CT7w8T/Ko5ExdA5BgpD3nE=; X-YMail-OSG: _HGtUw8VM1mqH31RshU4fnB5Cs.IQSKqBSk_xi.4GIblshH 1IJiGjvH3m4DvtMnYHg68pWjQ3j54CRrYH8kFjnRvp7hFMTBEebf9EkiSWLn cA6FhbsIaugGD8IAdJ.3ZHTGOPdovPHoFTxzG.fPqoYzOdyqugJQwUx4JewA yIooX01BlD89ejCWNuNPITVjuqJic3YCuvzbrvrSc29HBzRs4d9c0PzShg7z QcgFwa1vELbIP53NSve7esPWKR2Op3ETGBJ7L1Q_Hjzr3QyrYSf.HY9iTKpj utGDvno2HwIk9rjjGeP3azNrwi0Cl_iwRCNud66JiI35edBybhXaoJBMeKLj Le6nWTsLPL6NV.GcazcPXvIeJY.Nid7TkOnvYCeNqYDdVcJVpDDw1elNptJn a1GVrx0894VlAe1wHj9RkmyApYYmuUA1wFtVvYUXM.24TeK_sWN_lD6BqUHG SVMdArvwHjT8CazzcXRG8xVblCATosba6yiHGP5VrSYw.L6E18Kdh8eFKnjH cJBPBRc94JFU8RFWTsG1mehiTvb8kar3NnbYD5Todj5IkVZPTnh5Uui_OEke HWNTKiEzp Received: from [155.70.23.45] by web192706.mail.sg3.yahoo.com via HTTP; Fri, 28 Feb 2014 21:13:10 SGT X-Rocket-MIMEInfo: 002.001, aGksCnRoYW5reW91IGZvciBzdWdnZXN0aW9ucywgaXRzIHdvcmtpbmcgbm93LiBJIG1hIHJldHJpZXZpbmcgdGhlIGlkcyBpbiBhbiBpbnRbXSBhbmQgdGhlbiB1c2luZyBvbmUgbW9yZSBjdXJzb3IgdG8gcmVhZCBhbmQgcmV0dXJuIHVzaW5nIHRoZSBpbnRbXS4gCgoKCgoKT24gVGh1cnNkYXksIDI3IEZlYnJ1YXJ5IDIwMTQgODowNCBQTSwgVG9tIExhbmUgPHRnbEBzc3MucGdoLnBhLnVzPiB3cm90ZToKIApBTE1BIFRBSElSIDxhbG1haGVlbmEyMDAzQHlhaG9vLmNvLmluPiB3cml0ZXM6Cj4gSSB3YW50IHQBMAEBAQE- X-Mailer: YahooMailWebService/0.8.177.636 References: <1393503792.47079.YahooMailNeo@web192706.mail.sg3.yahoo.com> <30402.1393511579@sss.pgh.pa.us> Message-ID: <1393593190.2407.YahooMailNeo@web192706.mail.sg3.yahoo.com> Date: Fri, 28 Feb 2014 21:13:10 +0800 (SGT) From: ALMA TAHIR Reply-To: ALMA TAHIR Subject: Re: Function Issue To: Tom Lane Cc: "pgsql-sql@postgresql.org" In-Reply-To: <30402.1393511579@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="-897285659-318668661-1393593190=:2407" X-Pg-Spam-Score: -0.1 (/) 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 ---897285659-318668661-1393593190=:2407 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable hi,=0Athankyou for suggestions, its working now. I ma retrieving the ids in= an int[] and then using one more cursor to read and return using the int[]= . =0A=0A=0A=0A=0A=0AOn Thursday, 27 February 2014 8:04 PM, Tom Lane wrote:=0A =0AALMA TAHIR writes:=0A= > I want to open a ref cursor with select for update and then update=0A> th= e records and get the ref cursor in response back in java.=0A=0AYour functi= on has already sucked all the rows out of the cursor before=0Ait returns it= , so it's not surprising that further reads from the cursor=0Aproduce nothi= ng.=0A=0AYou could try rewinding the cursor (see MOVE) but I'm not sure tha= t will=0Ahelp in this case, since the function has carefully ensured that n= one of=0Athe rows pass the cursor query's WHERE condition anymore.=A0 I thi= nk that=0Asince the cursor used SELECT FOR UPDATE, it will not return the u= pdated=0Arows even after rewinding.=A0 (I could be wrong though, so it's wo= rth=0A=0Atrying.)=0A=0AI think you need to rethink what you're doing.=A0 Th= is seems like a fairly=0Asilly application design: why not do all the proce= ssing you need on these=0Arows in one place?=A0 Or at the very least, don't= use one cursor to serve=0Atwo masters.=A0 Possibly you could have the func= tion return the rows itself=0Ainstead of passing back a refcursor.=0A=0A=A0= =A0=A0 =A0=A0=A0 =A0=A0=A0 regards, tom lane=0A=0A=0A-- =0ASent via pgsql-s= ql mailing list (pgsql-sql@postgresql.org)=0ATo make changes to your subscr= iption:=0Ahttp://www.postgresql.org/mailpref/pgsql-sql ---897285659-318668661-1393593190=:2407 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
hi,
thankyou for s= uggestions, its working now. I ma retrieving the ids in an int[] and then u= sing one more cursor to read and return using the int[].

<= br>
On Thursday, 27 February 2014 8:04 PM, Tom Lane <tgl@sss.pgh.pa.us&g= t; wrote:
ALMA TAHIR <= ;almaheena2003@yahoo.co.in> 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 sucke= d all the rows out of the cursor before
it returns it, so= it's not surprising that further reads from the cursor
p= roduce nothing.

You could try rewindin= g the cursor (see MOVE) but I'm not sure that will
help i= n 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 w= ill not return the updated
rows even after rewinding.&nbs= p; (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 le= ast, don't use one cursor to serve
two masters.  Pos= sibly you could have the function return the rows itself
= instead of passing back a refcursor.

&= nbsp;           regards, tom lane

--
Sent via pgsql-sql mailing list (pgsql-sql@po= stgresql.org)
To make changes to your subscription:http://www.postgresql.org/mailpref/pgsql-sq= l



=20
---897285659-318668661-1393593190=:2407--