Database sessions are bound to the connection. Assuming that you followed general guidelines for performance you have a connection-pool. Basically connections are reused and as such the session is never destroyed.
Global temporary table throwing SQL Integrity constraint exception sometimes when invoking the stored proc
Pregunta
I'm trying to debug an error at work. It is using a stored procedure (in DB2) with a global temporary table to store and return back results. Consider the following code snippet inside the stored_proc
declare global temporary table session.details
(
row_count integer not null generated always as identity,
...
)
with replace on commit delete rows not logged on rollback delete rows;
The stored_proc itself is being called by Spring framework. The bug is that sometimes (very often actually) when Spring invokes the stored_proc I see errors like
[FMWGEN][DB2 JDBC Driver][DB2]INSERT/UPDATE INVALID; INDEX 1 RESTRICTS COLUMNS WITH SAME VALUES;
nested exception is java.sql.SQLIntegrityConstraintViolationException:
[FMWGEN][DB2 JDBC Driver][DB2]INSERT/UPDATE INVALID; INDEX 1 RESTRICTS COLUMNS WITH SAME VALUES
Here is the java code snippet invoking this stored_proc
SqlParameterSource parameterSource = new MapSqlParameterSource().addValue("v_input", input)
Map<String, Object> result = proc.execute(parameterSource);
proc is an instance variable
private SimpleJdbcCall proc
this.proc =new SimpleJdbcCall(dataSource)
.withSchemaName("schema")
.withProcedureName("proc")
.declareParameters(
new SqlParameter("v_input", java.sql.Types.INTEGER)
).returningResultSet("output", new CustomRowMapper<String>());
According to IBM DB2 docs the Global Temporary Table gets destroyed and recreated for every session, but from the sql exception seems like that is not happening? Any help is appreciated.
No hay solución correcta
Otros consejos
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow