在使用带有';'的SQL语句进行java.sql.SQLSyntaxErrorException: ORA-00911: invalid character
(1)调用时,是否有人遇到sql.execute('...')
中间的(分号)字符。我知道尾随分号导致ORA-00911如2所示,所以我已经将它们剥离出来了)
以下是一个这样的SQL语句的示例:
INSERT INTO metadata_property_qualifier(id,version,metadata_property_id,name,overridable,propagated,to_instance,to_subclass,translatable,type,value,value_type)
VALUES (mpr_qualifier_sequence.nextval,0,(select id from metadata_property where metadata_class_id
IN (select id from metadata_class where name = 'UIM_DXTPMLanSwitchError')
AND metadata_property.name='CollisNumberValidity'),'ValueMap',0,0,0,0,0,'[Ljava.lang.String;',unistr('0\00a31'),19)
请注意,[Ljava.lang.String;
中包含;
个字符。
有没有办法逃脱分号或以某种方式解决它?
代码段:
sqlFile.eachLine() {
log.info it
if(!it.startsWith('--') && !it.trim().isEmpty()) {
try {
sql.execute(it - ';')
} catch(ex) {
log.error ex
log.info "Rolling back the transaction..."
sql.dataSource.connection.rollback()
}
}
}