sp_iqlocks procedure

Function

Shows information about locks in the database, for both the IQ Store and the Catalog Store.

Syntax

sp_iqlocks ( [ connection,] [ [ owner.]table_name ] max_locks,] [sort_order ] )

Usage

Table 9-17 lists the optional sp_iqlocks parameters you can specify to restrict results.

Table 9-17: Optional sp_iqlocks parameters

Name

Data type

Description

connection

integer

Connection ID. With this option, the procedure returns information about locks for the specified connection only. Default is zero, which returns information about all connections

owner.table_ name

char (128)

Table name. With this option, the procedure returns information about locks for the specified table only. Default is NULL, which returns information about all tables in the database. If you do not specify owner, it is assumed that the caller of the procedure owns the table.

max_locks

integer

Maximum number of locks for which to return information. Default is 0 which returns all lock information.

sort_order

char(1)

Order in which to return information:

  • C sorts by connection (default)

  • T sorts by table_name

Description

Displays information about current locks in the database. Depending on the options you specify, you can restrict results to show locks for a single connection, a single table, or a specified number of locks.

The sp_iqlocks procedure displays the following information, sorted as specified in the sort_order parameter:

Table 9-18: sp_iqlocks columns

Column

Description

connection ID

Connection ID that has the lock

user name

User associated with this connection ID

table name

Table on which the lock is held

lock type

String of characters indicating the type of lock:

  • S Shared

  • E Exclusive

  • P Phantom

  • A Antiphantom

  • W Write

All locks listed have exactly one of S, E, or W, and may also have P, A, or both. Phantom and antiphantom locks also have a qualifier of T or *

  • T The lock is with respect to a sequential scan

  • * The lock is with respect to all scans

  • nnn Index number; the lock is with respect to a particular index

lock name

Value identifying the lock

If sp_iqlocks cannot find the connection ID or user name of the user who has a lock on a table, it displays a 0 (zero) for the connection id and User unavailable for the user name.

NoteExclusive, Phantom, or Anti-phantom locks can be placed on Adaptive Server Anywhere tables, but not on IQ tables. Unless you have explicitly taken out locks on a table in the Catalog Store, you will never see these types of locks (or their qualifiers T, *, and nnn) in an IQ database. For information on how locking works in Adaptive Server Anywhere tables, see the Adaptive Server Anywhere SQL User’s Guide.

Examples

The first example shows the sp_iqlocks procedure call and its output in an IQ database. The procedure is called with all default options, so that the output shows all locks, sorted by connection.

call sp_iqlocks()
connection      user_id table_name      lock_type       lock_name70187172        'mary'  'DBA.t2'        'S'             (NULL)
604945019       'russ'  'russ.t3'       'S'             (NULL)
604945019       'russ'  'russ.t3'       'W'             (NULL)
1550990889      'DBA'   'dbo.spt_mda'   'S'             (NULL)
1744647885      'DBA'   'russ.t1'       'S'             (NULL)
1744647885      'DBA'   'russ.t1'       'W'             (NULL)
1744647885      'DBA'   'russ.t3'       'S'             (NULL)
2120842322      'shemp' 'shemp.t1'      'S'             (NULL)
2120842322      'shemp' 'shemp.t1'      'W'             (NULL)

The next example shows sp_iqlocks with sorting by table name.

call sp_iqlocks(0,null,0,'t')
connection      user_id table_name      lock_type       lock_name70187172        'mary'  'DBA.t2'        'S'             (NULL)
1550990889      'DBA'   'dbo.spt_mda'   'S'             (NULL)
1744647885      'DBA'   'russ.t1'       'S'             (NULL)
1744647885      'DBA'   'russ.t1'       'W'             (NULL)
604945019       'russ'  'russ.t3'       'S'             (NULL)
604945019       'russ'  'russ.t3'       'W'             (NULL)
1744647885      'DBA'   'russ.t3'       'S'             (NULL)
2120842322      'shemp' 'shemp.t1'      'S'             (NULL)
2120842322      'shemp' 'shemp.t1'      'W'             (NULL)