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 14C8E9FB25B for ; Thu, 24 Aug 2006 17:11:05 -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 25923-01 for ; Thu, 24 Aug 2006 17:11:01 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from nf-out-0910.google.com (nf-out-0910.google.com [64.233.182.185]) by postgresql.org (Postfix) with ESMTP id 5A56E9FB24D for ; Thu, 24 Aug 2006 17:11:01 -0300 (ADT) Received: by nf-out-0910.google.com with SMTP id p77so729382nfc for ; Thu, 24 Aug 2006 13:10:59 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:mime-version:content-type; b=CqV6ehTnjMHCdldxt36Rt5n7+MBFIu6ysFsTB/k0gUg48kt3BhnHbmpsInoCUv2hcl9MxTVkQkCX349PhujVhm7zZHdUpYwFD72r6GWc97M1TUfx/17KaSOFP8V5F0qZ3Nft7EE5M0fTXov0AL0vh0SdvRPPm/2rPkA9SHPA7Kw= Received: by 10.49.55.13 with SMTP id h13mr4290785nfk; Thu, 24 Aug 2006 13:10:59 -0700 (PDT) Received: by 10.49.27.10 with HTTP; Thu, 24 Aug 2006 13:10:59 -0700 (PDT) Message-ID: <68d2080c0608241310o2d0a5a71l36496b2044571e2e@mail.gmail.com> Date: Thu, 24 Aug 2006 15:10:59 -0500 From: "yazmin morales" To: pgsql-jdbc@postgresql.org Subject: Cursor in JDBC MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_101807_30972047.1156450259535" X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.2 tagged_above=0 required=5 tests=DNS_FROM_RFC_ABUSE, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200608/127 X-Sequence-Number: 15654 ------=_Part_101807_30972047.1156450259535 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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,notefirstpmt,"); select.append ("noteclosed,noteDLP,lastname,firstname,suffix,birthdate,homephone,metro2cii,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. ------=_Part_101807_30972047.1156450259535 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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,notefirstpmt,");
select.append("noteclosed,noteDLP,lastname,firstname,suffix,birthdate,homephone,metro2cii,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.
------=_Part_101807_30972047.1156450259535--