oracle11g - Java iBatis Missing INTO Keyword -


i'm receiving error when run ibatis insert command:

debug [main] - returned connection 31746664 pool. debug [main] - checked out connection 31746664 pool. debug [main] - {conn-100014} connection debug [main] - {conn-100014} preparing statement:          insert 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 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:    --- error occurred in objectrelationalmapping.xml.   --- error occurred while applying parameter map.   --- check sectoranalysis.domain.insertportfolio-inlineparametermap.   --- check statement (update failed).   --- cause: java.sql.sqlsyntaxerrorexception: ora-00925: missing keyword 

the relevant bits in mapping file are:

     <insert id="insertportfolio" parameterclass="com.fimt.sectoranalysis.domain.portfolio.portfolio">         insert 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> 

i don't understand because keyword quite there. why oracle db returning error?

the syntaxt is:

insert (...) values (...) returning (...) (...) 

in example oracle complaining because expects second keyword. try using statement resultclass parameter:

<statement id="insertportfolio" parameterclass="com.fimt.sectoranalysis.domain.portfolio.portfolio" resultclass="int"> ...  </statement> 

for more examples please see: howto return ids on inserts ibatis ( returning keyword )


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -