When I do an insert with the SQL Anywhere 16 .net provider, it creates a shared lock on the table. even with a commit afterwards. How do I prevent it? (Or what am I doing wrong?)
asked 07 Apr '14, 16:49 rickrat |
I suspect you are looking at a schema lock here. Committing DML operations will release row locks but if the statement remains prepared then a schema lock is retained. The Command object will probably need to be freed via a Dispose( ) to release that. Of course closing the connection will also accomplish that. Schema locks only prevent DDL operations on those objects and can usually be ignored unless you alter your tables frequently enough for this to be an administrative barrier. answered 09 Apr '14, 11:11 Nick Elson S... |
Are you sure you see a lock after a COMMIT? ...or have you done some other operation like SELECT after the COMMIT? Please show us exactly what the lock looks like; e.g., in dbisql: SELECT * FROM sa_locks(); Here is a demonstration that shows a COMMIT clears all locks, but even a SELECT gets a schema lock: CREATE TABLE t ( pkey INTEGER NOT NULL PRIMARY KEY ); INSERT t VALUES ( 1 ); COMMIT; SELECT * FROM sa_locks(); -- no rows SELECT * FROM t; SELECT * FROM sa_locks(); -- conn_name,conn_id,user_id,table_type,creator,table_name,index_id,lock_class,lock_duration,lock_type,row_identifier -- 'ddd16-1',1,'DBA','BASE','DBA','t',,'Schema','Transaction','Shared', answered 09 Apr '14, 17:16 Breck Carter |