ERR-31386 ( 201606) Cannot perform a DML, commit, or rollback inside a query.#
Overview#
This document describes the cause of and solution for the ERR-31386 error that can occur while executing a SELECT statement.
Version#
Altibase 6.3.1 or later
Symptom#
The ERR-31386 error occurs when executing a SELECT statement that includes a function call.
Altibase 7.1 or later#
In Altibase 7.1 or later, the function name and the line number within the function where the error occurred are displayed.
[ERR-31386 : Cannot perform a DML, commit, or rollback inside a query.
at "SYS.FUNC1", line 6]
Altibase 6.3.1 and 6.5.1#
In Altibase 6.3.1 and 6.5.1, the function name and the statement where the error occurred are displayed.
[ERR-31386 : Cannot perform a DML, commit, or rollback inside a query.
In FUNC1
0004 : insert into T1 values(C1);
^ ^
]
The following example shows the error that occurs when a function containing an INSERT statement is called from a SELECT statement.
iSQL> CREATE OR REPLACE FUNCTION func1()
RETURN VARCHAR(10)
AS
c1 VARCHAR(10);
BEGIN
INSERT INTO t1 VALUES(c1);
RETURN c1;
END;
/
Create success.
iSQL> SELECT func1() FROM DUAL;
[ERR-31386 : Cannot perform a DML, commit, or rollback inside a query.
at "SYS.FUNC1", line 6]
Cause#
This error occurs when a function called while executing a SELECT statement performs a data modification statement such as INSERT, UPDATE, or DELETE, or performs COMMIT or ROLLBACK.
In the example above, the error occurs because the FUNC1 function called from the SELECT statement executes the following INSERT statement.
INSERT INTO t1 VALUES(c1);
Solution#
Check the function indicated in the error message for the SELECT statement, and modify the function so that it does not perform INSERT, UPDATE, or DELETE statements, or COMMIT or ROLLBACK.
Reference#
Differences in Error Messages by Version
In Altibase 6.1.1 or earlier, the same condition results in the ERR-1105D error. Starting from Altibase 6.3.1, the ERR-31386 error is reported.
ERR-1105D ( 69725) Unable to begin a new update statement.