public static RptCBpartnerData[] select( ConnectionProvider connectionProvider, String adLanguage, String cBpartnerId, int firstRegister, int numberRegisters) throws ServletException { String strSql = ""; strSql = strSql + " SELECT BP.C_BPARTNER_ID, BP.VALUE, AD_MESSAGE_GET2(BP.ISACTIVE, ?) AS ISACTIVE, TO_DATE(BP.CREATED) AS CREATED, TO_DATE(BP.UPDATED) AS UPDATED, " + " BP.NAME, BP.NAME2, G.NAME AS GROUPNAME, BP.TAXID, '' AS ACCOUNTNO, AD_MESSAGE_GET2(BP.ISEMPLOYEE, ?) AS ISEMPLOYEE, AD_MESSAGE_GET2(BP.ISSALESREP, ?) AS ISSALESREP, " + " ISCUSTOMER, ISVENDOR, '' AS SEQNO, '' AS CASCADE, '' AS DISCOUNT, '' AS QTY, '' AS CLASS_TREE" + " FROM C_BPARTNER BP, C_BP_GROUP G" + " WHERE BP.C_BP_GROUP_ID = G.C_BP_GROUP_ID"; strSql = strSql + ((cBpartnerId == null || cBpartnerId.equals("")) ? "" : " AND BP.C_BPARTNER_ID IN " + cBpartnerId); ResultSet result; Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0); PreparedStatement st = null; int iParameter = 0; try { st = connectionProvider.getPreparedStatement(strSql); iParameter++; UtilSql.setValue(st, iParameter, 12, null, adLanguage); iParameter++; UtilSql.setValue(st, iParameter, 12, null, adLanguage); iParameter++; UtilSql.setValue(st, iParameter, 12, null, adLanguage); if (cBpartnerId != null && !(cBpartnerId.equals(""))) {} result = st.executeQuery(); long countRecord = 0; long countRecordSkip = 1; boolean continueResult = true; while (countRecordSkip < firstRegister && continueResult) { continueResult = result.next(); countRecordSkip++; } while (continueResult && result.next()) { countRecord++; RptCBpartnerData objectRptCBpartnerData = new RptCBpartnerData(); objectRptCBpartnerData.cBpartnerId = UtilSql.getValue(result, "c_bpartner_id"); objectRptCBpartnerData.value = UtilSql.getValue(result, "value"); objectRptCBpartnerData.isactive = UtilSql.getValue(result, "isactive"); objectRptCBpartnerData.created = UtilSql.getDateValue(result, "created", "dd-MM-yyyy"); objectRptCBpartnerData.updated = UtilSql.getDateValue(result, "updated", "dd-MM-yyyy"); objectRptCBpartnerData.name = UtilSql.getValue(result, "name"); objectRptCBpartnerData.name2 = UtilSql.getValue(result, "name2"); objectRptCBpartnerData.groupname = UtilSql.getValue(result, "groupname"); objectRptCBpartnerData.taxid = UtilSql.getValue(result, "taxid"); objectRptCBpartnerData.accountno = UtilSql.getValue(result, "accountno"); objectRptCBpartnerData.isemployee = UtilSql.getValue(result, "isemployee"); objectRptCBpartnerData.issalesrep = UtilSql.getValue(result, "issalesrep"); objectRptCBpartnerData.iscustomer = UtilSql.getValue(result, "iscustomer"); objectRptCBpartnerData.isvendor = UtilSql.getValue(result, "isvendor"); objectRptCBpartnerData.seqno = UtilSql.getValue(result, "seqno"); objectRptCBpartnerData.cascade = UtilSql.getValue(result, "cascade"); objectRptCBpartnerData.discount = UtilSql.getValue(result, "discount"); objectRptCBpartnerData.qty = UtilSql.getValue(result, "qty"); objectRptCBpartnerData.classTree = UtilSql.getValue(result, "class_tree"); objectRptCBpartnerData.position = Long.toString(countRecord); objectRptCBpartnerData.InitRecordNumber = Integer.toString(firstRegister); vector.addElement(objectRptCBpartnerData); if (countRecord >= numberRegisters && numberRegisters != 0) { continueResult = false; } } result.close(); } catch (SQLException e) { log4j.error("SQL error in query: " + strSql + "Exception:" + e); throw new ServletException( "@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); } catch (Exception ex) { log4j.error("Exception in query: " + strSql + "Exception:" + ex); throw new ServletException("@CODE=@" + ex.getMessage()); } finally { try { connectionProvider.releasePreparedStatement(st); } catch (Exception ignore) { ignore.printStackTrace(); } } RptCBpartnerData objectRptCBpartnerData[] = new RptCBpartnerData[vector.size()]; vector.copyInto(objectRptCBpartnerData); return (objectRptCBpartnerData); }
public static RptCBpartnerData[] selectDiscount( ConnectionProvider connectionProvider, String cBpartnerId, int firstRegister, int numberRegisters) throws ServletException { String strSql = ""; strSql = strSql + " SELECT (CASE BD.CASCADE WHEN 'Y' THEN 'Si' ELSE 'No' END) AS CASCADE, BD.LINE AS SEQNO, D.NAME, D.DISCOUNT" + " FROM C_BPARTNER_DISCOUNT BD, C_DISCOUNT D" + " WHERE BD.C_DISCOUNT_ID = D.C_DISCOUNT_ID"; strSql = strSql + ((cBpartnerId == null || cBpartnerId.equals("")) ? "" : " AND BD.C_BPARTNER_ID IN " + cBpartnerId); strSql = strSql + " ORDER BY SEQNO"; ResultSet result; Vector<java.lang.Object> vector = new Vector<java.lang.Object>(0); PreparedStatement st = null; try { st = connectionProvider.getPreparedStatement(strSql); if (cBpartnerId != null && !(cBpartnerId.equals(""))) {} result = st.executeQuery(); long countRecord = 0; long countRecordSkip = 1; boolean continueResult = true; while (countRecordSkip < firstRegister && continueResult) { continueResult = result.next(); countRecordSkip++; } while (continueResult && result.next()) { countRecord++; RptCBpartnerData objectRptCBpartnerData = new RptCBpartnerData(); objectRptCBpartnerData.cascade = UtilSql.getValue(result, "cascade"); objectRptCBpartnerData.seqno = UtilSql.getValue(result, "seqno"); objectRptCBpartnerData.name = UtilSql.getValue(result, "name"); objectRptCBpartnerData.discount = UtilSql.getValue(result, "discount"); objectRptCBpartnerData.position = Long.toString(countRecord); objectRptCBpartnerData.InitRecordNumber = Integer.toString(firstRegister); vector.addElement(objectRptCBpartnerData); if (countRecord >= numberRegisters && numberRegisters != 0) { continueResult = false; } } result.close(); } catch (SQLException e) { log4j.error("SQL error in query: " + strSql + "Exception:" + e); throw new ServletException( "@CODE=" + Integer.toString(e.getErrorCode()) + "@" + e.getMessage()); } catch (Exception ex) { log4j.error("Exception in query: " + strSql + "Exception:" + ex); throw new ServletException("@CODE=@" + ex.getMessage()); } finally { try { connectionProvider.releasePreparedStatement(st); } catch (Exception ignore) { ignore.printStackTrace(); } } RptCBpartnerData objectRptCBpartnerData[] = new RptCBpartnerData[vector.size()]; vector.copyInto(objectRptCBpartnerData); return (objectRptCBpartnerData); }