|
SELECT AFIELD1,AFIELD2,BFIELD1,CASE BFIELD2 is null THEN '' ELSE BFIELD2 END Should work. Royce Stearns Manage, Inc. (503) 353-1721 x103 www.manageinc.com Keith_McCully@wund erman.co.uk To: java400-l@midrange.com Sent by: cc: java400-l-admin@mi Subject: ResultSet null column drange.com 07/31/2002 05:18 AM Please respond to java400-l I have built a prepared statement that links data from 2 DB2/400 tables. Left join is used because there will not always be a key matched row in table B but I would always expect 1 row from table A. PreparedStatement stmt1 = connection.prepareStatement("SELECT AFIELD1, AFIELD2, BFIELD1, BFIELD2 FROM A LEFT JOIN B ON AFIELD1 = BFIELD1 WHERE AFIELD1 = ?") After I do a stmt1.executeQuery() into a ResultSet (rs) and then extract BFIELD2 as String FIELDX = rs.getString("BFIELD2").trim() If a matched row in file B exists when I load FIELDX, then everything works fine but ,if not ,then I get a NullPointerException. I tried testing rs.getString for null prior to FIELDX load but no success. Any comments and suggestions on how to check for null would be very welcome! Thanks, Keith _______________________________________________ This is the Java Programming on and around the iSeries / AS400 (JAVA400-L) mailing list To post a message email: JAVA400-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/java400-l or email: JAVA400-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/java400-l.
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.