Informix Error -705: Cannot drop/modify procedure procedure-name. It is currently in use. An attempt was made either to drop a currently executing procedure or to run UPDATE STATISTICS on a currently running procedure. This condition can occur if a procedure tries to drop itself or if a nested procedure tries to drop a procedure that called it.
Cause and resolution
Cannot drop/modify procedure procedure-name. It is currently in use. An attempt was made either to drop a currently executing procedure or to run UPDATE STATISTICS on a currently running procedure. This condition can occur if a procedure tries to drop itself or if a nested procedure tries to drop a procedure that called it.
Example of error:
CREATE PROCEDURE testproc() ... DROP PROCEDURE testproc; -- error END PROCEDURE
Correction: You can use an ON EXCEPTION statement to trap this error and not carry out the DROP PROCEDURE or UPDATE STATISTICS statement.
This error also occurs if you try to drop a function or procedure that a functional index is using.
This error also occurs if you try to drop a function or procedure that a xadatasource type is using.
Oninit® Troubleshooting Guidance
Reasons / Common Causes
-705 fires in several distinct situations, per the official guidance: dropping a currently
executing procedure, running UPDATE STATISTICS on a currently running procedure, a procedure
attempting to drop itself, a nested procedure trying to drop the procedure that called it, or
attempting to drop a function/procedure that a functional index or an xadatasource type is
currently using.
- A procedure attempting to drop itself, per the official guidance's specific example — the procedure is, by definition, in use while it's running.
- A nested procedure trying to drop a procedure that called it, per the official guidance — the caller is still active on the call stack.
DROP/UPDATE STATISTICStargeting a procedure while it's actively executing (in any session, not necessarily the one attempting the drop).- A function/procedure backing a functional index, or used by an
xadatasourcetype, per the official guidance — dropping it would break that dependency while it's in use.
Solutions / Resolution
- Use an
ON EXCEPTIONstatement to trap this error, per the official guidance's documented correction, and simply not carry out theDROP PROCEDURE/UPDATE STATISTICSstatement if the procedure turns out to be self-referential or otherwise in use — this is the recommended pattern for the self-drop/nested-caller scenarios specifically. - Wait until the procedure isn't actively executing before attempting to drop it or run
UPDATE STATISTICS, for the general in-use case. - Check whether a functional index or
xadatasourcetype depends on the routine, per the official guidance, before attempting to drop it — remove or redefine that dependency first if the drop is genuinely intended.
Examples
A procedure trying to drop itself, trapped with ON EXCEPTION
CREATE PROCEDURE self_destruct()
ON EXCEPTION IN (-705)
-- -705 trapped: this procedure is currently in use (it's running), skip the DROP
END EXCEPTION
DROP PROCEDURE self_destruct;
END PROCEDURE;
Checking for a functional-index dependency
SELECT idxname FROM sysindexes WHERE tabid =
(SELECT tabid FROM systables WHERE tabname = 'documents');
-- review whether any listed index is functional and depends on the routine
-- being dropped
Diagnostic Checks
- Determine which of the several scenarios applies: self-drop, nested-caller drop, a
currently-executing procedure in another session, or a functional-index/
xadatasourcedependency. - For the self-drop/nested-caller case, wrap the
DROP/UPDATE STATISTICSin anON EXCEPTIONper the official guidance, rather than trying to avoid the condition structurally.
Related Errors / Related Topics
No closely related error codes are cross-referenced for -705 in this set yet.
For a self-drop or nested-caller scenario specifically, the official guidance's own recommended
fix is to trap the error with ON EXCEPTION rather than avoid it structurally.