DERBY-534: Support use of the WHEN clause in CREATE TRIGGER statements

Fix incorrect null check when merging subqueryTrackingArray and
materializedSubqueries in GenericStatementContext.setTopResultSet().
Used to cause NullPointerException in some cases when a WHEN clause
contained a subquery.

Add more tests for scalar subqueries in WHEN clauses.