JdbcTemplate batchUpdate 可以在插入操作中使用序列吗?

huangapple go评论88阅读模式
英文:

JdbcTemplate batchUpdate is it possible to use a sequence in the insert?

问题

batchUpdate方法的插入操作中使用序列是否可能?
我没有找到有关这个主题的任何信息。

  1. jdbcTemplate.batchUpdate(
  2. "INSERT INTO TUR1HV01.UR1_CP_GOR (id, GOR_NAME) values (select TUR1HV01.SEQ_CP_GOR_MODEL.nextval from dual, ?)",
  3. gorList,
  4. 10000,
  5. (ps, argument) -> {
  6. ps.setString(1, argument.getGorName());
  7. });

异常:
Caused by: Error : 936, Position : 56, Sql = INSERT INTO TUR1HV01.UR1_CP_GOR (id, GOR_NAME) values (select TUR1HV01.SEQ_CP_GOR_MODEL.nextval from dual, :1 ), OriginalSql = INSERT INTO TUR1HV01.UR1_CP_GOR (id, GOR_NAME) values (select TUR1HV01.SEQ_CP_GOR_MODEL.nextval from dual, ?), Error Msg = ORA-00936: missing expression

我应该使用触发器来代替吗?

英文:

Is it possible to use a sequence in the insert of a call to the batchUpdate method?
I've not found anything on this subject.

  1. jdbcTemplate.batchUpdate(
  2. "INSERT INTO TUR1HV01.UR1_CP_GOR (id, GOR_NAME) values (select TUR1HV01.SEQ_CP_GOR_MODEL.nextval from dual, ?)",
  3. gorList,
  4. 10000,
  5. (ps, argument) -> {
  6. ps.setString(1, argument.getGorName());
  7. });

Exception:
Caused by: Error : 936, Position : 56, Sql = INSERT INTO TUR1HV01.UR1_CP_GOR (id, GOR_NAME) values (select TUR1HV01.SEQ_CP_GOR_MODEL.nextval from dual, :1 ), OriginalSql = INSERT INTO TUR1HV01.UR1_CP_GOR (id, GOR_NAME) values (select TUR1HV01.SEQ_CP_GOR_MODEL.nextval from dual, ?), Error Msg = ORA-00936: missing expression

shlould I use a trigger insetad?

答案1

得分: 1

values (TUR1HV01.SEQ_CP_GOR_MODEL.nextval, ?) should work.

英文:
  1. values (TUR1HV01.SEQ_CP_GOR_MODEL.nextval, ?)

should work.

huangapple
  • 本文由 发表于 2023年3月10日 00:42:59
  • 转载请务必保留本文链接:https://go.coder-hub.com/75687585.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定