ORA-933 Error When Using Select for Update With NOWAIT and SKIP LOCKED Against 11g Oracle Database Worked With 10.2 (Doc ID 1296385.1)

Last updated on JULY 05, 2017

Applies to:

PL/SQL - Version 11.2.0.2 and later
Information in this document applies to any platform.
***Checked for relevance on 13-Aug-2012***

Symptoms

After an upgrade of the Oracle database from 10.2.0.5 to 11.2.0.2, a SQL statement using 'UPDATE OF STATUS NOWAIT SKIP LOCKED' fails with:

ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at line 6

The same sql statement executed against a 10.2.0.4 or 10.2.0.5 Oracle Database works finr without errors.

set serveroutput on;

CREATE TABLE MQ_MSG_DETAILS
(
SYSTEM_DATE DATE NOT NULL,
MESSAGE BLOB DEFAULT EMPTY_BLOB(),
MQ_MSG_ID VARCHAR2(50 BYTE) NOT NULL,
MQ_MSG_SEQ NUMBER(10) NOT NULL,
MSG_SOURCE VARCHAR2(15 BYTE) NOT NULL,
STATUS CHAR(1 BYTE) NOT NULL
);

Table created.

CREATE UNIQUE INDEX PK_MQ_MSG_DETAILS ON MQ_MSG_DETAILS (MQ_MSG_SEQ, MQ_MSG_ID, SYSTEM_DATE);

Index created.

CREATE PUBLIC SYNONYM MQ_MSG_DETAILS FOR MQ_MSG_DETAILS;

Synonym created.

ALTER TABLE MQ_MSG_DETAILS ADD ( CONSTRAINT CH_MQ_MSG_DETAILS CHECK (STATUS IN ('R','P','I')));

Table altered.

ALTER TABLE MQ_MSG_DETAILS ADD ( CONSTRAINT PK_MQ_MSG_DETAILS
PRIMARY KEY (MQ_MSG_SEQ, MQ_MSG_ID, SYSTEM_DATE));

Table altered.

DECLARE
TYPE ControlCursorType IS REF CURSOR;
control_cursor ControlCursorType;
my_key NUMBER;
BEGIN
OPEN control_cursor FOR
'select mq_msg_Seq from mq_msg_details where mq_msg_seq=59310 FOR UPDATE OF STATUS NOWAIT SKIP LOCKED';
LOOP
FETCH control_cursor INTO my_key;
EXIT WHEN control_cursor%NOTFOUND;
DBMS_OUTPUT.PUT_LINE(' Value ' || my_key );
END LOOP;
CLOSE control_cursor;
END;
/
DECLARE
*
ERROR at line 1:
ORA-00933: SQL command not properly ended
ORA-06512: at line 6

Changes

Upgraded the Oracle Database from 10.2 to 11.2.0.2.

Cause

Sign In with your My Oracle Support account

Don't have a My Oracle Support account? Click to get started

My Oracle Support provides customers with access to over a
Million Knowledge Articles and hundreds of Community platforms