我试图在数据库中插入 CLOB
(见 < a href=
insert all
into domo_queries values ( select
substr(to_char(max_data),1,4) as year,
substr(to_char(max_data),5,6) as month,
max_data
from dss_fin_user.acq_dashboard_src_load_success
where source = CHQ PeopleSoft FS )
select * from dual;
最终,这 < a href=> http://www.techonthenet.com/oracle/ questions/ Indeplication_rows.php> rel=“noreferr”\code> 插入所有 声明将有很多 into
s。 这就是为什么我只是不做一个常规的 Indement
声明。我看不到里面有无效的字符,你呢? (Oh,当我用我的 sql 开发工具 < / strenger> 运行它时, < 坚固> 代码是好的) 。 如果我删除了 < code> prepared state 中的分号 <, 它会扔出一个 < code> ORA- 00933: SQL 命令没有正确结束 错误。
无论如何,这里是用于执行查询(以及上述变量的值)的代码。
public ResultSet executeQuery(String connection, String query, QueryParameter... params) throws DataException, SQLException {
// query at this point = "insert all
//into domo_queries values (?)
//select * from dual;"
Connection conn = ConnectionPool.getInstance().get(connection);
PreparedStatement pstmt = conn.prepareStatement(query);
for (int i = 1; i <= params.length; i++) {
QueryParameter param = params[i - 1];
switch (param.getType()) { //The type in the example is QueryParameter.CLOB
case QueryParameter.CLOB:
Clob clob = CLOB.createTemporary(conn, false, oracle.sql.CLOB.DURATION_SESSION);
clob.setString(i, " " + param.getValue() + " ");
//the value of param.getValue() at this point is:
/*
* select
* substr(to_char(max_data),1,4) as year,
* substr(to_char(max_data),5,6) as month,
* max_data
* from dss_fin_user.acq_dashboard_src_load_success
* where source = CHQ PeopleSoft FS
*/
pstmt.setClob(i, clob);
break;
case QueryParameter.STRING:
pstmt.setString(i, " " + param.getValue() + " ");
break;
}
}
ResultSet rs = pstmt.executeQuery(); //Obviously, this is where the error is thrown
conn.commit();
ConnectionPool.getInstance().release(conn);
return rs;
}
有什么我错过了大日子吗?