Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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

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.

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

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

values (TUR1HV01.SEQ_CP_GOR_MODEL.nextval, ?)

should work.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading