Re: Function Issue

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: ALMA TAHIR <almaheena2003(at)yahoo(dot)co(dot)in>
Cc: "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org>
Subject: Re: Function Issue
Date: 2014-02-27 14:32:59
Message-ID: 30402.1393511579@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

ALMA TAHIR <almaheena2003(at)yahoo(dot)co(dot)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 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

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message David Johnston 2014-02-27 15:09:34 Re: how to effectively SELECT new "customers"
Previous Message Jan Ostrochovsky 2014-02-27 14:20:18 how to effectively SELECT new "customers"