0

iBatis 挿入コマンドを実行すると、次のエラーが表示されます。

DEBUG [main] - Returned connection 31746664 to pool.
DEBUG [main] - Checked out connection 31746664 from pool.
DEBUG [main] - {conn-100014} Connection
DEBUG [main] - {conn-100014} Preparing Statement:          INSERT INTO PORTFOLIOS              ( theme_id             , start_date             , portfolio_name             , amount             , index_cd             , model_cd             , last_rebalance             , months_between_rebalance             )         VALUES             ( 1             , SYSDATE             , ?             , ?             , ?             , ?             , SYSDATE             , ?)         RETURNING portfolio_id     
DEBUG [main] - {pstm-100015} Executing Statement:          INSERT INTO PORTFOLIOS              ( theme_id             , start_date             , portfolio_name             , amount             , index_cd             , model_cd             , last_rebalance             , months_between_rebalance             )         VALUES             ( 1             , SYSDATE             , ?             , ?             , ?             , ?             , SYSDATE             , ?)         RETURNING portfolio_id     
DEBUG [main] - {pstm-100015} Parameters: [testPortfolio2New, 100000.0, null, null, 0]
DEBUG [main] - {pstm-100015} Types: [java.lang.String, java.lang.Double, null, null, java.lang.Integer]
com.ibatis.common.jdbc.exception.NestedSQLException:   
--- The error occurred in ObjectRelationalMapping.xml.  
--- The error occurred while applying a parameter map.  
--- Check the sectoranalysis.domain.insertPortfolio-InlineParameterMap.  
--- Check the statement (update failed).  
--- Cause: java.sql.SQLSyntaxErrorException: ORA-00925: missing INTO keyword

私のマッピングファイルの関連ビットは次のとおりです。

     <insert id="insertPortfolio" parameterClass="com.fimt.sectoranalysis.domain.portfolio.Portfolio">
        INSERT INTO PORTFOLIOS 
            ( theme_id
            , start_date
            , portfolio_name
            , amount
            , index_cd
            , model_cd
            , last_rebalance
            , months_between_rebalance
            )
        VALUES
            ( 1
            , SYSDATE
            , #name#
            , #investment#
            , #index.ticker#
            , #model.modelId#
            , SYSDATE
            , #frequency#)
        RETURNING portfolio_id
    </insert>

INTOキーワードがかなり明確にあるため、わかりません。Oracle DB がこのエラーを返すのはなぜですか?

4

1 に答える 1

1

構文は次のとおりです。

INSERT INTO (...) VALUES (...) RETURNING (...) INTO (...)

あなたの例では、Oracleは2番目のINTOキーワードを期待しているため、不平を言っています。resultClass パラメーターを使用してステートメントを使用してみます。

<statement id="insertPortfolio" parameterClass="com.fimt.sectoranalysis.domain.portfolio.Portfolio" resultClass="int">
... 
</statement>

その他の例については、以下を参照してください: Ibatis を使用したインサートの ID を返す方法 ( w​​ith RETURNING キーワード )

于 2013-10-16T18:55:24.240 に答える