function createDataset(fields, constraints, sortFields) {
    var dataset = DatasetBuilder.newDataset();
    dataset.addColumn("codigo");
    dataset.addColumn("descricao");

    var dataSource = "/jdbc/ProtheusP12";
    var ic = new javax.naming.InitialContext();
    var conn = null;
    var stmt = null;
    var rs = null;

    try {
        var ds = ic.lookup(dataSource);
        conn = ds.getConnection();

        var sql = "SELECT b1_cod, b1_desc FROM sb1010 WHERE LEFT(b1_cod, 4) IN ('0001','0008', '0002', '0003', '0007', '0006', '0009', '0010', '0011', '0014','0016') OR b1_cod LIKE 'PROD0%'";
        stmt = conn.prepareStatement(sql);
        rs = stmt.executeQuery();

        var encontrados = {};

        while (rs.next()) {
            var codigo = rs.getString("b1_cod");
            var descricao = rs.getString("b1_desc");

            if (!encontrados[codigo]) {
                encontrados[codigo] = true;
                dataset.addRow([codigo, descricao]);
            }
        }

    } catch (e) {
        log.error("Erro ao executar dataset: " + e.message);
        // Garantir retorno de dataset mesmo em caso de erro
    } finally {
        try { if (rs) rs.close(); if (stmt) stmt.close(); if (conn) conn.close(); } catch(e) {}
    }

    return dataset;
}
