我正在尝试在表中插入新行,该行是从同一表中选择的行的副本。我创建了一个过程,它根据表中的 id 选择行,并用一些新值插入回同一个表中。该过程还返回新行的 PK。
当我执行 CallableStatement 时,出现以下异常:
java.sql.SQLException: ORA-06550: line 1, column 371:
PL/SQL: ORA-00933: SQL command not properly ended
ORA-06550: line 1, column 7:
PL/SQL: SQL Statement ignored
at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
我找不到错误
Commond没有正确结束
在我的程序中
我的代码供参考。任何帮助或提示表示赞赏。谢谢你。
public void updateFileToThisVersion(VaMediaFile fileDTO, Long fromMediaId){
Connection conn = null;
CallableStatement cst = null;
try {
String insertQuery = "BEGIN INSERT INTO VA_MEDIA_FILE (VMF_ID, VMF_FILE_NAME, VMF_FILE, VMF_FILE_CONTENT_TYPE, VMF_FILE_VER_NUM, VMF_IS_ACTIVE, VMF_UPLOADED_BY_ROLE_ID, VMF_UPLOADED_BY_USER_ID, VMF_UPLOADED_TS, VMF_COMMENTS) " +
" (SELECT VMF_ID_SEQ_NUM.NEXTVAL, VMF_FILE_NAME, VMF_FILE, VMF_FILE_CONTENT_TYPE, ?, 'Y', ?, ?, SYSDATE, VMF_COMMENTS FROM VA_MEDIA_FILE where VMF_ID = ?) RETURNING VMF_ID INTO ?; END;";
conn = getConnection();
conn.setAutoCommit(false);
cst = conn.prepareCall(insertQuery);
cst.setString(1, fileDTO.getFileVerNum());
cst.setString(2, fileDTO.getUploadedByRoleId());
cst.setString(3, fileDTO.getUploadedByUserId());
cst.setLong(4, fromMediaId);
cst.registerOutParameter(5, Types.NUMERIC);
cst.execute();
long newRecordId = cst.getLong(5);
if(newRecordId != 0L){
conn.commit();
}
} catch (Exception sqlException) {
} finally {
OracleDaoUtils.closeQuietly(cst, conn);
}
}