|
I am testing a prototype DB2/400 connection/update class in QSH - eventually to be executed from a servlet. I am having a problem updating a field which is numeric 5 0 packed. I am creating a SQL PreparedStatement object for performance reasons in the DB connection method: getSalesCnt = dbConnection.prepareStatement("SELECT CLIENTS "+ "FROM SALES WHERE DISTRICT = ? FOR UPDATE"); getSalesCnt.setCursorName("SAL"); setSalesCnt = dbConnection.prepareStatement("UPDATE SALES "+ "SET CLIENTS = ? WHERE CURRENT OF SAL"); In the update method I create the record set OK: ResultSet rs = null; getSalesCnt.setString(1, loc); rs = getSalesCnt.executeQuery(); // Extract the count from the result set rs.next(); BigDecimal count = rs.getBigDecimal("CLIENTS", 0); However, the method throws an SQLException on the following line when I try to increment the number of clients by 1 : setSalesCnt.setString(1, count.add(new BigDecimal(1)).toString()); I tried an alternative line: setSalesCnt.setString(1, count.add(new BigDecimal(1))); But this also threw an SQLException. What is the correct syntax for this update? Any assistance very much appreciated. Keith __________________________________________________________________ This transmission has been issued by a member of the HSBC group ("HSBC") for the information of the addressee only and should not be reproduced and / or distributed to any other person. Each page attached hereto must be read in conjunction with any disclaimer which forms part of it. This transmission is neither an offer nor the solicitation of an offer to sell or purchase any investment. Its contents are based on information obtained from sources believed to be reliable but HSBC makes no representation and accepts no responsibility or liability as to its completeness or accuracy. +--- | This is the JAVA/400 Mailing List! | To submit a new message, send your mail to JAVA400-L@midrange.com. | To subscribe to this list send email to JAVA400-L-SUB@midrange.com. | To unsubscribe from this list send email to JAVA400-L-UNSUB@midrange.com. | Questions should be directed to the list owner: joe@zappie.net +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.