I store sql-queries in resource files with pretty human-readable formatting(with line breaks and indents). Suddenly I faced with issue: simple query, like below, works fine without fetching generated code-column value via keyholder,
insert into
my_table
(
code
)
values
(
my_table_seq.nextval
)
but return ORA-00931: missing identifier\n when keyholder used:
...
var keyHolder = new GeneratedKeyHolder();
jdbcTemplate.update(
"MY INSERT QUERY",
new MapSqlParameterSource(),
keyHolder,
new String[]{"code"}
);
...
I debugged oracle jdbc driver(ojdbc8/ojdbc10 19.24) and noticed that whitespace after into-keyword cause this behaviour: AutoKeyInfo.getTableName return "\n" instead of "MY_TABLE"(see image below)! Removing whitespace solved the issue.
Is it bug(and is it possible to submit it to ojdbc developers)?

>Solution :
Is it a bug?
Yes… The code looks for INSERT then INTO and then skips space characters and assumes that the next non-space character is the start of the identifier for the table name. When it finds a new-line character, it assumes that is the start of the identifier and returns a single new-line character instead of the actual identifier.
What it should do is skip whitespace characters rather than just spaces.
However… The work-around is simple, don’t use non-space whitespace characters in INSERT INTO my_table, just use spaces between the keywords and the identifier.
So, yes, you could report it but, in the meanwhile, you should be able to easily fix your code so it doesn’t trigger the issue.