Essence: I write the xml parser, which then hangs the results in a table. If true, some value (for example: clientID == 0 ) - no recording is necessary. I can not think how to do it.

  • Banal if, chains of predicates. - a_gura
  • that is, something like this, if (ps.clientID == 0) ps.clear (); else ps.executebatch; //? - Deexof
  • Do you have a problem with parsing xml or branching? - Vladislav Pyatkov
  • There the problem is somewhat different. xml is parsed and placed in caents (some representation of the table (element index and block address in xml)), then 5 fields are added to each container common to each table, then this container is transferred to PS. There are several entries at a time, in different tables. In my head, at least, I need to put a check on the necessary value before the executive, if I put it where it is happening now, I will have to produce a lot of checks. And so, for three containers out of 15, in the event that one column is zero. - Deexof

1 answer 1

For example, something like this:

 if (product != null && location != null && courseType != null && category != null) { pstmt = conn.prepareStatement("select * FROM Courses WHERE " + "product = ? " + "and location = ? " + "and courseType = ? " + "and category = ?"); pstmt.setString(1, product); pstmt.setString(2, location); pstmt.setString(3, courseType); pstmt.setString(4, category); } else if (product == null && location != null && courseType != null && category != null) { pstmt = conn.prepareStatement("select * FROM Courses WHERE " + "location = ? " + "and courseType = ? " + "and category = ?"); pstmt.setString(1, location); pstmt.setString(2, courseType); pstmt.setString(3, category); }