Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: JDBC and RETURNING clause

Re: JDBC and RETURNING clause

From: Joel R. Kallman <jkallman_at_us.oracle.com>
Date: Mon, 13 Nov 2000 15:20:39 GMT
Message-ID: <3a100694.7911395@newshost.us.oracle.com>

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(); 
        } 

    }
[snip]

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



The statements and opinions expressed here are my own and do not necessarily represent those of Oracle Corporation. Received on Mon Nov 13 2000 - 09:20:39 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US