ORACLE異常:RETURNING 子句不支援的功能

來源:互聯網
上載者:User

標籤:資料庫表   oracle   number   exception   returnning   

擷取序列ID時出現的異常,檢查oracle資料庫表ID欄位類型是否為NUMBER類型。如果是long修改為number即可。有關number類型:http://www.blogjava.net/caojianhua/archive/2011/01/24/343461.html嚴重: nulljava.sql.SQLException: ORA-22816: RETURNING 子句不支援的功能at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:110)at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:171)at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:947)at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3462)at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1061)at org.iie.dao.impl.OracleGenelDaoImpl.insertDataReturnKeyByReturnInto(OracleGenelDaoImpl.java:160)at org.iie.dao.impl.OracleGenelDaoImpl.main(OracleGenelDaoImpl.java:148)

順便貼出擷取序號的方法:


public static int insertDataReturnKeyByReturnInto() throws Exception {        Connection conn = GlobalData.getOracleConnection();        String vsql = "insert into xx(id) values(xx_squencee.nextval) returning id into :1";        OraclePreparedStatement pstmt = (OraclePreparedStatement) conn.prepareStatement(vsql);        pstmt.registerReturnParameter(1, Types.BIGINT);        pstmt.executeUpdate();        ResultSet rs = pstmt.getReturnResultSet();        rs.next();        int id = rs.getInt(1);        rs.close();        pstmt.close();        System.out.print("id:" + id);        return id;    }


本文出自 “我會努力” 部落格,請務必保留此出處http://meijia.blog.51cto.com/8684191/1586548

ORACLE異常:RETURNING 子句不支援的功能

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.