From: Richard on
Our web programmer was looking in his application log an found the
following error:

2006-08-31 16:33:35,129 ERROR org.hibernate.util.JDBCExceptionReporter
- <[IBM][CLI Driver][DB2/6000] SQL0723N An error occurred in a
triggered SQL statement in trigger "OLGCWEB.TBLPROPS_INS_TRG".
Information returned for the error includes SQLCODE "-811", SQLSTATE
"21000" and message tokens "". SQLSTATE=09000
> (JDBCExceptionReporter.java.logExceptions:72)
2006-08-31 16:33:35,139 ERROR
org.hibernate.event.def.AbstractFlushingEventListener - <Could not
synchronize database state with session>
(AbstractFlushingEventListener.java.performExecutions:277)
org.hibernate.exception.GenericJDBCException: could not insert:
[ca.olgc.proline.domain.PropDO]
at
org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:82)
at
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:70)
at
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
at
org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1869)
at
org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2200)
at
org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
at
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
at
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
at
org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
at
ca.olgc.proline.dao.hibernate.BaseHibernateDAO.batchSaveOrUpdate(BaseHibernateDAO.java(Compiled
Code))
at
ca.olgc.proline.facade.sessionbeans.PropicksCardBean.addOrUpdateProPicksCard(PropicksCardBean.java:233)
at
ca.olgc.proline.facade.sessionbeans.EJSLocalStatelessPropicksCard_464a659b.addOrUpdateProPicksCard(EJSLocalStatelessPropicksCard_464a659b.java:159)
at
ca.olgc.proline.facade.ProlineFacadeBean.addOrUpdateProPicksCard(ProlineFacadeBean.java:780)
at
ca.olgc.proline.facade.EJSRemoteStatelessProlineFacade_cc482172.addOrUpdateProPicksCard(EJSRemoteStatelessProlineFacade_cc482172.java:567)
at
ca.olgc.proline.facade._ProlineFacade_Stub.addOrUpdateProPicksCard(_ProlineFacade_Stub.java:1579)
at
ca.olgc.proline.messaging.helper.DatabaseUpdateHelper.add(DatabaseUpdateHelper.java:106)
at
ca.olgc.proline.messaging.helper.DatabaseUpdateHelper.updateDB(DatabaseUpdateHelper.java:50)
at
ca.olgc.proline.messaging.mdb.SportsRefresherBean.updateDB(SportsRefresherBean.java:81)
at
ca.olgc.proline.messaging.mdb.SportsRefresherBean.onMessage(SportsRefresherBean.java:65)
at
com.ibm.ejs.jms.listener.MDBWrapper$PriviledgedOnMessage.run(MDBWrapper.java:208)
at java.security.AccessController.doPrivileged(Native Method)
at
com.ibm.ejs.jms.listener.MDBWrapper.callOnMessage(MDBWrapper.java:197)
at com.ibm.ejs.jms.listener.MDBWrapper.onMessage(MDBWrapper.java:175)
at com.ibm.mq.jms.MQSession.run(MQSession.java(Compiled Code))
at com.ibm.ejs.jms.JMSSessionHandle.run(JMSSessionHandle.java:923)
at
com.ibm.ejs.jms.listener.ServerSession.connectionConsumerOnMessage(ServerSession.java:739)
at
com.ibm.ejs.jms.listener.ServerSession.onMessage(ServerSession.java:524)
at
com.ibm.ejs.jms.listener.ServerSession.dispatch(ServerSession.java:491)
at java.lang.reflect.Method.invoke(Native Method)
at
com.ibm.ejs.jms.listener.ServerSessionDispatcher.dispatch(ServerSessionDispatcher.java:37)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:91)
at com.ibm.ejs.container.MDBWrapper.onMessage(MDBWrapper.java:127)
at com.ibm.ejs.jms.listener.ServerSession.run(ServerSession.java:373)
at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:681)
Caused by:
COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/6000] SQL0723N An
error occurred in a triggered SQL statement in trigger
"OLGCWEB.TBLPROPS_INS_TRG". Information returned for the error
includes SQLCODE "-811", SQLSTATE "21000" and message tokens "".
SQLSTATE=09000
at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java(Compiled
Code))
at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(SQLExceptionGenerator.java(Inlined
Compiled Code))
at
COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(SQLExceptionGenerator.java(Compiled
Code))
at
COM.ibm.db2.jdbc.app.DB2PreparedStatement.execute2(DB2PreparedStatement.java(Compiled
Code))
at
COM.ibm.db2.jdbc.app.DB2PreparedStatement.executeUpdate(DB2PreparedStatement.java:1642)
at
com.ibm.ws.rsadapter.jdbc.WSJdbcPreparedStatement.executeUpdate(WSJdbcPreparedStatement.java:462)
at
org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at
org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1853)
... 33 more
2006-08-31 16:33:35,156 ERROR ca.olgc.proline.dao.hibernate.CardDAOImpl
- <Exception encountered in saveOrUpdate()> (?.java:?)



I'm not sure what this is telling me. The Db2 Administration Guide
says:

sqlcode: -811

sqlstate: 21000

SQL0817N The SQL statement cannot be executed because the statement
will result in a prohibited update operation.


Explanation: The application attempted to execute an SQL statement that
would result in updates to user data or to the subsystem catalog. This
is prohibited for one of the following reasons:

The application is running as an IMS inquiry-only transaction.
The application is an IMS or CICS application that is attempting to
update data at a remote DBMS that does not support two-phase commit.
The application is attempting to update data at multiple locations and
one of the locations does not support two-phase commit.
These SQL statements include INSERT, UPDATE, DELETE, CREATE, ALTER,
DROP, GRANT, and REVOKE.

The statement cannot be executed.

User Response: If the application is running as an IMS inquiry-only
transaction, see your IMS system programmer about changing the
inquiry-only status of the transaction under which your application is
running.

If the IMS or CICS application is attempting a remote update, either
the application must be changed to r
From: Knut Stolze on
Richard wrote:

> Our web programmer was looking in his application log an found the
> following error:
>
> 2006-08-31 16:33:35,129 ERROR org.hibernate.util.JDBCExceptionReporter
> - <[IBM][CLI Driver][DB2/6000] SQL0723N An error occurred in a
> triggered SQL statement in trigger "OLGCWEB.TBLPROPS_INS_TRG".
> Information returned for the error includes SQLCODE "-811", SQLSTATE
> "21000" and message tokens "". SQLSTATE=09000
>> (JDBCExceptionReporter.java.logExceptions:72)
> 2006-08-31 16:33:35,139 ERROR
> org.hibernate.event.def.AbstractFlushingEventListener - <Could not
> synchronize database state with session>
> (AbstractFlushingEventListener.java.performExecutions:277)
> org.hibernate.exception.GenericJDBCException: could not insert:
> [ca.olgc.proline.domain.PropDO]
> at
> [...]
>
> I'm not sure what this is telling me. The Db2 Administration Guide
> says:
>
> sqlcode: -811
>
> sqlstate: 21000
>
> SQL0817N The SQL statement cannot be executed because the statement
> will result in a prohibited update operation.

$ db2 "? sql0811"

SQL0811N The result of a scalar fullselect, SELECT INTO
statement, or VALUES INTO statement is more than one
row.

> There's only one database involved, Here's the SQL from the trigger:
>
> CREATE TRIGGER TBLPROPS_ins_trg
> NO CASCADE
> BEFORE INSERT ON TBLPROPS REFERENCING NEW AS T1 FOR EACH ROW
> MODE DB2SQL
> SET T1.PROD_GROUP_TYPE_CODE = 'LOTPRPICKS',
> T1.PARTICIPANT_DESC = (SELECT TEAM_NAME FROM TBLCARDS T2,
> TBLTEAMNAMES T3
> WHERE T3.TEAM_ABBR = T1.PARTICIPANT and
> T3.SPORT_ID = T2.SPORT_ID and
> T2.CARD_ID = T1.CARD_ID and
> T2.LIST_NUMBER = T1.LIST_NUMBER)

According to the error message, your subselect returns more than one row.
Of course, this cannot be handled safely. If you don't care about which
row to use, then you could apply the FETCH FIRST 1 ROW ONLY clause. If the
row matters, find the correct one.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany