Fire Sequence.nextval request using jdbctemplate in spring

Database: Oracle

I have a table in which there are 10 columns, and I want the following next value after the insert row, and also use that serial number that was inserted.

Now I searched and found that the KeyHolder from spring is useful, but it only limits the field to at least 8, so I cannot use it.

How can I run a query "select MySequence.nextval from dual"and get the sequence using jdbctemplate(NamedParameterJDBCTemplate)?

Is there any other way to achieve to get the entered sequence value ?.

+4
source share
1 answer

jdbctemplate, , .

jdbcTemplate.update("INSERT INTO TABLE (id, data) VALUES (MySequence.nextval, ?)", new Object[] { data });

: Oracle 12c , . 12c .

+1

All Articles