如何在 SQL 中复制 %Dictionary.ClassDefintionQuery 的 Summary()?

How do I replicate %Dictionary.ClassDefintionQuery's Summary() in SQL?

%Dictionary.ClassDefinitionQuery 中有一个程序列出了 class 摘要;在 Java 我这样称呼它:

public void readClasses(final Path dir)
    throws SQLException
{
    final String call
        = "{ call %Dictionary.ClassDefinitionQuery_Summary() }";

    try (
        final CallableStatement statement = connection.prepareCall(call);
        final ResultSet rs = statement.executeQuery();
    ) {
        String className;
        int count = 0;

        while (rs.next()) {
            // Skip if System is not 0
            if (rs.getInt(5) != 0)
                continue;

            className = rs.getString(1);

            // Also skip if the name starts with a %
            if (className.charAt(0) == '%')
                continue;

            //System.out.println(className);
            count++;
        }

        System.out.println("read: " + count);
    }
}

在命名空间 SAMPLES 中这 returns 491 行。

我尝试用这样的纯 SQL 查询复制它:

private void listClasses(final Path dir)
    throws SQLException
{
    final String query = "select id, super"
        + " from %Dictionary.ClassDefinition"
        + " where System = '0' and name not like '\%%' escape '\'";

    try (
        final PreparedStatement statement
            = connection.prepareStatement(query);
        final ResultSet rs = statement.executeQuery();
    ) {
        int count = 0;

        while (rs.next()) {
            //System.out.println(rs.getString(1) + ';' + rs.getString(2));
            count++;
        }

        System.out.println("list: " + count);
    }
}

然而当 运行 我得到这个程序时:

list: 555
read: 491

为什么结果不同?

我看过 %Dictionary.ClassDefinitionQuery 的代码,但我不明白为什么它会给出不同的结果...我所知道的是,如果我将名称存储在集合中并进行比较,是:

但仅此而已。

如何在 SQL 中复制摘要过程的行为?

不同之处在于一个属性。 %Dictionary.ClassDefinitionQuery_Summary 仅显示 classes with Deployed<>2。所以,sql一定是这样的。

select id,super from %Dictionary.ClassDefinition where deployed <> 2

但还有一件事是,为什么计数可能不同是,这样的 sql 请求可能会被编译为临时 class,例如“%sqlcq.SAMPLES.cls22”