Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Codeblock
languagejs
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 expresionsexpressions:
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)),
            lastname: Strings.nn(rs.getString(3)),
            length: rs.getInt(3)4)
        });
    }
};
script.add(sqlQuery);

// Start execution:
script.execute();

...