oracle 错误 java.sql.SQLException: ORA-01722: 运行准备语句以更改序列时的无效数字
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5841131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:32:33 来源:igfitidea点击:
ERROR java.sql.SQLException: ORA-01722: invalid number while running a Prepared Statement to alter a Sequence
提问by smriti
sqlStmt = new StringBuffer(" ALTER SEQUENCE " );
sqlStmt.append( ServerContext.getSchemaName() );
sqlStmt.append("SEQ_EDCD_TRACE_NUM");
sqlStmt.append( " INCREMENT BY " );
sqlStmt.append( " ? " );
pstmt.setLong(1, incval);
pstmt.execute();
回答by Luke Woodward
You can't use bind variables with DDL, such as ALTER SEQUENCE
. You'll have to concatenate incval
onto the string.
不能在 DDL 中使用绑定变量,例如ALTER SEQUENCE
. 您必须连接incval
到字符串上。
There shouldn't be any risk of SQL injection if incval
is an int
or a long
.
如果incval
是 anint
或 a ,则不应有任何 SQL 注入风险long
。