|
Well, I learned that the hard way too. It would appear that when building an SQL statement, you don't actually use the data types. You just use a string representation of it. I think it's because if you do a STRSQL on the AS/400 and use it that way, you are actually in effect keying a string to the 400, not a value. So when you build your statement via code, it's the same principal. As for converting the numbers over, I have no idea. Never done it yet. For setting my values for those numbers on the 400 I just use the setString, setInt, and setDouble etc. before I do an update or insert. ie.: updateGarbage = conn.prepareStatement( "UPDATE " + collectionName + dmd.getCatalogSeparator() + garbschedmstTable + " SET WGSCHDID=?, WGCUSTID=?, " + "WGCALLDT=?, WGCALLTM=?, WGSPICKD=?, WGAPPCNT=?, WGAPPNUM=?, WGSTATUS=?, WGSTREAS=?, WGPYWAIVD=?, WGPAYAMNT=?, " + "WGCONTRID=?, WGSDATE=?, WGRDATE=?, WGXCOORD=?, WGYCOORD=?, WGUSERID=?, WGSP30A=?, WGSP20A=?, WGSP10A=?, " + "WGSP05A=?, WGSP01A=?, WGSP92S=?, WGSP72S=?, WGSP52S=?, WGSP90S=?, WGSP70S=?, WGSP50S=?, WGSP30S=?, WGSP10S=?, WGOVRIDE=? WHERE WGSCHDID = ? AND WGCUSTID = ?"); updateGarbage.setString(1, b.getGarbageId()); updateGarbage.setString(2, b.getCustId()); updateGarbage.setInt(3, b.getCallRecDate()); updateGarbage.setString(4, b.getCallRecTime()); updateGarbage.setInt(5, b.getSchedPickUpDate()); updateGarbage.setInt(6, b.getAppointmentCount()); updateGarbage.setInt(7, b.getAppointmentNumber()); updateGarbage.setString(8, b.getStatus()); updateGarbage.setString(9, b.getStatusReasonCode()); updateGarbage.setString(10, b.getPaymentWaived()); updateGarbage.setDouble(11, b.getPaymentAmount()); updateGarbage.setString(12, b.getContractorId()); updateGarbage.setInt(13, b.getDateSentToContractor()); updateGarbage.setInt(14, b.getDateRecFromContractor()); updateGarbage.setString(15, b.getXCoOrd()); updateGarbage.setString(16, b.getYCoOrd()); updateGarbage.setString(17, b.getUserId()); updateGarbage.setString(18, b.getSpare30a()); updateGarbage.setString(19, b.getSpare20a()); updateGarbage.setString(20, b.getSpare10a()); updateGarbage.setString(21, b.getSpare05a()); updateGarbage.setString(22, b.getSpare01a()); updateGarbage.setDouble(23, b.getSpare92s()); updateGarbage.setDouble(24, b.getSpare72s()); updateGarbage.setDouble(25, b.getSpare52s()); updateGarbage.setDouble(26, b.getSpare90s()); updateGarbage.setDouble(27, b.getSpare70s()); updateGarbage.setInt(28, b.getSpare50s()); updateGarbage.setInt(29, b.getSpare30s()); updateGarbage.setInt(30, b.getSpare10s()); updateGarbage.setString(31, b.getOverrideSchedPickUpDate()); updateGarbage.setString(32, b.getGarbageId()); updateGarbage.setString(33, b.getCustId()); numUpd = updateGarbage.executeUpdate(); updateGarbage.close(); Ron Power Programmer Information Services City Of St. John's, NL P.O. Box 908 St. John's, NL A1C 5M2 Tel: 709-576-8132 Email: rpower@xxxxxxxxxx Website: http://www.stjohns.ca/ ___________________________________________________________________________ Success is going from failure to failure without a loss of enthusiasm. - Sir Winston Churchill "Anand, Rajesh" <Rajesh_Anand@xxxxxx> Sent by: java400-l-bounces@xxxxxxxxxxxx 27/06/2005 02:37 PM Please respond to Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx> To "Java Programming on and around the iSeries / AS400" <java400-l@xxxxxxxxxxxx> cc Subject RE: Error when converting Java Types to AS400 data Types Thanks Ron, Its worked, but I'm confused as ever. When would you change from java types to as400 types as we didn't have to change on this occasion??? rgds, Rajesh Anand Email:Rajesh_anand@xxxxxx -----Original Message----- From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of RPower@xxxxxxxxxx Sent: 27 June 2005 17:44 To: Java Programming on and around the iSeries / AS400 Subject: RE: Error when converting Java Types to AS400 data Types Ah ok. I think I might see your problem. Give this a try, build your "values" as just strings and see what happens. I've built my SQL statements for the DB2 when accessing zone fields as just strings and it seems to be fine. ie. String civicno; String unit; String street; civicno = req.getParameter("civicno").trim(); unit = req.getParameter("unit").trim(); street = req.getParameter("street").trim(); getCustomers = conn.prepareStatement( "SELECT * FROM " + collectionName + dmd.getCatalogSeparator() + custTable + " WHERE WCSTREET# = " + street + " AND WCCIVIC# = '" + civicno + "'"); Ron Power Programmer Information Services City Of St. John's, NL P.O. Box 908 St. John's, NL A1C 5M2 Tel: 709-576-8132 Email: rpower@xxxxxxxxxx Website: http://www.stjohns.ca/ ________________________________________________________________________ ___ Success is going from failure to failure without a loss of enthusiasm. - Sir Winston Churchill "Anand, Rajesh" <Rajesh_Anand@xxxxxx> Sent by: java400-l-bounces@xxxxxxxxxxxx 27/06/2005 02:00 PM Please respond to Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx> To "Java Programming on and around the iSeries / AS400" <java400-l@xxxxxxxxxxxx> cc Subject RE: Error when converting Java Types to AS400 data Types Ron, Not sue what you mean, but as an example. Date[0] = 2005-03-01 and closingprice = 4.77686. When converted to BigDecimal converts to 050103 & 4.77 respectively and this is converted to AS400ZonedDecimal. The sqlstmt = "Insert into BLMINTF1 (RTDTE, RTRATE) values (xxxx, xxxx)" where xxxx looks like some gibberish in Qshell. rgds, Rajesh Anand Email:Rajesh_anand@xxxxxx -----Original Message----- From: java400-l-bounces@xxxxxxxxxxxx [mailto:java400-l-bounces@xxxxxxxxxxxx] On Behalf Of RPower@xxxxxxxxxx Sent: 27 June 2005 17:24 To: Java Programming on and around the iSeries / AS400 Subject: Re: Error when converting Java Types to AS400 data Types Would you mind posting the value that prints out for sqlstmt? Ron Power Programmer Information Services City Of St. John's, NL P.O. Box 908 St. John's, NL A1C 5M2 Tel: 709-576-8132 Email: rpower@xxxxxxxxxx Website: http://www.stjohns.ca/ ________________________________________________________________________ ___ Success is going from failure to failure without a loss of enthusiasm. - Sir Winston Churchill "Anand, Rajesh" <Rajesh_Anand@xxxxxx> Sent by: java400-l-bounces@xxxxxxxxxxxx 27/06/2005 01:25 PM Please respond to Java Programming on and around the iSeries / AS400 <java400-l@xxxxxxxxxxxx> To <java400-l@xxxxxxxxxxxx> cc Subject Error when converting Java Types to AS400 data Types Folks, Another bit of help needed from experts in this forum. Here is the snippet of my code where I'm converting Java String types to Zoned Decimal As400 Types. Both Date[] and closingprice [] are of types String. The file BLMINTF1 has both these fields defined as Zoned. String d1 = date[i].substring(3,4)+ date[i].substring(9,10) + date[i].substring(6,7); BigDecimal d2 = new BigDecimal(d1); byte[] asd2 = new AS400ZonedDecimal(6,0).toBytes(d2); BigDecimal bd1 = new BigDecimal(closingprice[i]); byte[] asbd1 = new AS400ZonedDecimal(15,5).toBytes(bd1); sqlstmt = "Insert into BLMINTF1 (" + field1 + "," + field2 + ")" + " values (" + asd2 + "," + asbd1 + ")"; System.out.println(sqlstmt); stmt.executeUpdate(sqlstmt); con.close(); When I run this pgm, I get an error during Insert statement. java.sql.SQLException: ^SQL0104] Token ^ was not valid. Valid tokens: ( + - ? : DAY RRN CASE CAST CHAR DAYS HOUR LEFT NULL TRIM U SER. java/lang/Throwable.<init>(Ljava/lang/String;)V+4 (Throwable.java:94) java/lang/Exception.<init>(Ljava/lang/String;)V+1 (Exception.java:42) java/sql/SQLException.<init>(Ljava/lang/String;Ljava/lang/String;I)V+1 (SQLException.java:43) com/ibm/as400/access/JDError.throwSQLException(Lcom/ibm/as400/access/AS4 00JDBCConnection;III)V+0 (JDError.java:517) com/ibm/as400/access/AS400JDBCStatement.commonPrepare(Lcom/ibm/as400/acc ess/JDSQLStatement;)Lcom/ibm/as400/access/JDServerR ow;+0 (AS400JDBCStatement.java:920) Thanks for your help in advance, Rajesh Anand Email:Rajesh_anand@xxxxxx -------------------------------------------------------- If you are not an intended recipient of this e-mail, please notify the sender, delete it and do not read, act upon, print, disclose, copy, retain or redistribute it. Click here for important additional terms relating to this e-mail. http://www.ml.com/email_terms/ --------------------------------------------------------
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.