Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: JDBC and RETURNING clause
As of JDBC Release 8.1.7, DML Returning is not supported by any of the JDBC drivers (thin, OCI, or kernel).
Although there is no native support for DML Returning in the drivers, you can still implement it via PL/SQL from JDBC.
Below is code snippet example of implementing DML Returning via pl/sql from JDBC:
[snip]
static private void testCallable(String longStr, int id)
throws SQLException {
CallableStatement cstmt = null; try { cstmt = conn.prepareCall ("BEGIN INSERT INTO TEST (ID, VAL) " + "VALUES (" + id + ",?) RETURNING ID INTO ?; END;"); cstmt.setString(1, longStr); cstmt.registerOutParameter(2, Types.INTEGER); int rowsUpdated = cstmt.executeUpdate(); String idStr = cstmt.getString(2); conn.commit(); System.out.println("Callable statement test inserted " + rowsUpdated + " row and returned ID=" + idStr); } catch ( SQLException e ) { conn.rollback(); descException(e, "testCallable()"); } finally { if (cstmt != null) cstmt.close(); }
On Sat, 11 Nov 2000 20:29:56 +0200, "Dmitry" <ndf_at_mail.ru> wrote:
>Hello All,
>
>Can I execute DML statement with RETURNING clause by JDBC?
>For example:
>
>UPDATE Scott.Dept
>SET DNAME = :DNAME
>WHERE DEPTNO = 10
>RETURNING DNAME
>INTO :DNAME
>
>Best regards
>Dmitry
>
>
>
Thanks!
Joel
Joel R. Kallman Oracle Service Industries
Columbus, OH jkallman@us.oracle.com http://www.oracle.com