gpt4 book ai didi

Java iBatis 缺少 INTO 关键字

转载 作者:行者123 更新时间:2023-12-01 14:02:39 25 4
gpt4 key购买 nike

当我运行 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 数据库返回此错误?

最佳答案

语法是:

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

在您的示例中,Oracle 正在提示,因为它需要第二个 INTO 关键字。我会尝试使用带有 resultClass 参数的语句:

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

有关更多示例,请参阅: Howto return ids on Inserts with Ibatis ( with RETURNING keyword )

关于Java iBatis 缺少 INTO 关键字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19227284/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com