X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 11BCB9FB25B for ; Thu, 24 Aug 2006 17:33:48 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 12943-07 for ; Thu, 24 Aug 2006 17:33:40 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey- Received: from net2.micro-automation.com (net2.micro-automation.com [64.7.141.29]) by postgresql.org (Postfix) with SMTP id A84DC9FB24D for ; Thu, 24 Aug 2006 17:33:40 -0300 (ADT) Received: (qmail 16404 invoked from network); 24 Aug 2006 20:33:39 -0000 Received: from dcdsl.ebox.com (HELO ?192.168.1.2?) (davec@64.7.143.116) by net2.micro-automation.com with SMTP; 24 Aug 2006 20:33:39 -0000 In-Reply-To: <68d2080c0608241310o2d0a5a71l36496b2044571e2e@mail.gmail.com> References: <68d2080c0608241310o2d0a5a71l36496b2044571e2e@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v752.2) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Cc: pgsql-jdbc@postgresql.org Content-Transfer-Encoding: 7bit From: Dave Cramer Subject: Re: Cursor in JDBC Date: Thu, 24 Aug 2006 16:33:39 -0400 To: yazmin morales X-Mailer: Apple Mail (2.752.2) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.044 tagged_above=0 required=5 tests=AWL, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/128 X-Sequence-Number: 15655 Please contact the pljava folks, this is the jdbc list. Dave On 24-Aug-06, at 4:10 PM, yazmin morales wrote: > Hello > > I have been trying to implement a cursor in a pljava using the > JDBC, but I get an error when I run de function, which is the > following: > SPI function SPI_prepare failed with error code -5 > How can I solve this error? Here is the code that I am using: > > StringBuffer select = new StringBuffer(); > select.append("select distinct on (n.companyid,n.custid) > n.companyid,n.custid,n.noteid,ssn,"); > select.append > ("dateadded,notetotal,interest,fee1,notepayments,notetype,notepmt,"); > select.append > ("metro2asc,n.notecage,notestatus,metro2sc,metro2cc,n.notebalance,note > firstpmt,"); > select.append > ("noteclosed,noteDLP,lastname,firstname,suffix,birthdate,homephone,met > ro2cii,country,"); > select.append("address,city,state,zip,getDueAmount > (n.noteid,"+ConstantsEngine.LEDGER+"),"); > select.append("getPmtHist(c.custid,''"+iDate+"'',''"+eDate > +"''),f.amount,f.trantype ,a.postdate,f2.amount as > woff,equifaxId,experianId,transunionId from "); > select.append(viewCusts+" as c JOIN "); > select.append(viewNotes+" as n USING (custid,companyid) LEFT OUTER > JOIN "); > select.append(viewFintrans+" as f ON (n.noteid =f.noteid and > (credit="+ConstantsEngine.LEDGER+" or debit="+ConstantsEngine.LEDGER > +") "); > select.append("and (trantype=1 or trantype=-1) and date( f.postdate) > >=date(''"+initDate.toSqlFull(company.getTZ())+"'') "); > select.append("and date(f.postdate)<=date(''"+limitDate.toSqlFull > (company.getTZ())+"'')) LEFT OUTER JOIN "+viewAgehist+" as a "); > select.append("ON (n.noteid=a.noteid and a.notecage=''30 days'')"); > select.append(" LEFT OUTER JOIN "+viewFintrans+" as f2 ON (n.noteid > =f2.noteid and f2.credit=10610 and f2.trantype=20)"); > select.append(" LEFT OUTER JOIN "+viewCompany+" as cp ON > (cp.companyid =n.companyid)"); > select.append(" WHERE n.custid=c.custid "); > select.append(" and ((notestatus=4 or notestatus=1 or date > (noteclosed)>=date(''"+endDate.toSqlFull( company.getTZ())+"'')))"); > select.append(" and date(noteclosed)<=date(''"+limitDate.toSqlFull > (company.getTZ())+"'') and "); > select.append("date(notemade)<=date(''"+limitDate.toSqlFull > ( company.getTZ())+"'') order by n.companyid,n.custid,postdate desc"); > Statement m_statement = DriverManager.getConnection > ("jdbc:default:connection").createStatement(); > int result = m_statement.executeUpdate("DECLARE metro2cursor CURSOR > FOR "+select.toString()); > ResultSet rs = m_statement.executeQuery("fetch all in metro2cursor"); > if(rs!=null){ > while(rs.next()){ > //get data > String companyId = rs.getString("companyId"); > } > } > m_statement.executeUpdate("CLOSE metro2cursor"); > m_statement.close(); > > Thanks for any help.