The following example illustrates how to generate and modify an SQL query statement to iterate over a set of UM entries without the overhead of having CSE instantiate an Entry
instance for each entry:
const results = []; const script = new SqlScript(); // We start with a UM query expression: const fragment = UM.query('defined(firstname) and isSet(cmsbs.isadmin)').toSqlFragment(); // As this would yield OIDs only, we add some columns we are interested in: fragment.addColumn('firstname'); fragment.addColumn('lastname'); // We can also SELECT raw SQL expresions: fragment.addRawColumn('LENGTH(firstname)'); const sqlQuery = fragment.toQuery(); // See the actual SQL query statement: console.log(sqlQuery.sql); // Iterate all results without pagination: sqlQuery.resultCallback = function(rs) { while (rs.next()) { results.push({oid: rs.getLong(1), firstname: Strings.nn(rs.getString(2)), length: rs.getInt(3)}); } }; script.add(sqlQuery); // Start execution: script.execute();