What is the equivalent of Oracle’s REF CURSOR in MySQL when using JDBC?

Posted by dacracot on Stack Overflow See other posts from Stack Overflow or by dacracot
Published on 2008-11-07T22:58:44Z Indexed on 2010/06/01 19:03 UTC
Read the original article Hit count: 1133

Filed under:
|
|
|
|

In Oracle I can declare a reference cursor...

TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE;

...and use it to pass a cursor as the return value...

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;

...and then capture it as a result set using 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);

What is the equivalent in MySQL?

© Stack Overflow or respective owner

Related posts about java

Related posts about mysql