1

在 Oracle 中,我可以声明一个引用游标...

TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE;

...并使用它来传递游标作为返回值...

FUNCTION end_spool
    RETURN t_spool
    AS
    v_spool t_spool;
    BEGIN
        COMMIT;
        OPEN v_spool FOR
            SELECT
                *
            FROM
                spool
            WHERE
                key = g_spool_key
            ORDER BY
                seq;
        RETURN v_spool;
    END end_spool;

...然后使用 JDBC 将其捕获为结果集...

private Connection conn;
private CallableStatement stmt;
private OracleResultSet rset;
[...clip...]
stmt = conn.prepareCall("{ ? = call " + call + "}");
stmt.registerOutParameter(1, OracleTypes.CURSOR);
stmt.execute();
rset = (OracleResultSet)stmt.getObject(1);

Postgresql 中的等价物是什么?

4

1 回答 1

4

也许这会有所帮助:http: //jdbc.postgresql.org/documentation/83/callproc.html#callproc-resultset-setof

我之前并没有真正搞砸过:P

于 2008-09-17T21:37:50.063 回答