cancel
Showing results for 
Search instead for 
Did you mean: 

Why does DROP SEQUENCE fail "in use by another connection"?

Breck_Carter
Participant
810

(update: scroll down for a workaround)


Here's the simple V17 reproducible; the database is empty, and there is no "other connection".

-- V17
SELECT @@VERSION;
CREATE SEQUENCE s;
MESSAGE STRING ( 's.nextval = ', s.nextval ) TO CONSOLE;
DROP SEQUENCE s;
SELECT '...done' AS status;

@@VERSION
'17.0.9.4882'

s.nextval = 1

Could not execute statement.
Sequence 's' in use by another connection
SQLCODE=-1366, ODBC 3 State="40001"
Line 5, column 1
You can continue executing or stop.
DROP SEQUENCE s

status
'...done'


The exact same code works in V16.

-- V16
SELECT @@VERSION;
CREATE SEQUENCE s
MESSAGE STRING ( 's.nextval = ', s.nextval ) TO CONSOLE;
DROP SEQUENCE s;
SELECT '...done' AS status;

@@VERSION
'16.0.0.2512'

s.nextval = 1

status
'...done'

Easy Workaround: Don't call s.nextval in a MESSAGE statement. ...which is easy in the real world, because calling nextval in a MESSAGE statement makes no sense :) It's a benign error, but... even benign errors can be canaries in the mineshaft; i.e., hargingers of doom :)
-- V17
-- Workaround: Don't call s.nextval in MESSAGE statement.
BEGIN
SELECT @@VERSION;
CREATE SEQUENCE s;
DECLARE @diagnostic LONG VARCHAR;
SELECT STRING ( 's.nextval = ', s.nextval ) INTO @diagnostic;
MESSAGE STRING ( @diagnostic ) TO CONSOLE;
DROP SEQUENCE s;
SELECT '...done' AS status;
END;

@@VERSION
'17.0.9.4882'

s.nextval = 1

status
'...done'

Accepted Solutions (0)

Answers (0)