X-Original-To: pgsql-jdbc-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id A50DC329C89 for ; Fri, 17 Sep 2004 23:55:14 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 41933-06 for ; Fri, 17 Sep 2004 22:55:08 +0000 (GMT) Received: from yass.opencloud.co.nz (yass.opencloud.co.nz [203.79.85.162]) by svr1.postgresql.org (Postfix) with ESMTP id 40553329CE3 for ; Fri, 17 Sep 2004 23:55:09 +0100 (BST) Received: from 203-79-104-60.cable.paradise.net.nz ([203.79.104.60] helo=opencloud.com) by yass.opencloud.co.nz with asmtp (Exim 3.35 #1 (Debian)) id 1C8RdA-00056m-00; Sat, 18 Sep 2004 10:55:04 +1200 Message-ID: <414B6B45.20900@opencloud.com> Date: Sat, 18 Sep 2004 10:55:01 +1200 From: Oliver Jowett User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6b) Gecko/20031205 Thunderbird/0.4 X-Accept-Language: en-us, en MIME-Version: 1.0 To: James Ireland Cc: pgsql-jdbc@postgresql.org Subject: Re: Fetching rows from a cursor returned by a stored function References: <414AFFAD.6040404@halfcab.com> In-Reply-To: <414AFFAD.6040404@halfcab.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200409/87 X-Sequence-Number: 10977 James Ireland wrote: > Hi everybody > > I have a stored function that returns a large number of rows as a > cursor. I am trying to prevent the entire result set being returned at > once. The code fragment below hits an OutOfMemoryError on the > "while(resultSet.next())" line, which I believe is for this reason. Unfortunately the current driver does not support cursor-based retrieval for functions that return refcursors: it grabs the whole resultset at once when the refcursor is retrieved as Types.OTHER. If you don't mind the ugliness, you could register the result parameter as Types.VARCHAR; that will give you a cursor name that you can then use to execute FETCH queries yourself. It might even work to execute FETCH FORWARD ALL for the cursor with a non-zero fetchsize (and let the driver manage incremental fetches) but I'm not sure what the behaviour of a non-zero row limit on a FETCH query is at the protocol level.. -O