Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 17 » SQL Anywhere Server - SQL Reference » System procedures » Alphabetical list of system procedures

sa_describe_cursor system procedure

Describes the name and type information for the columns of a cursor.

Syntax
sa_describe_cursor( cursor_name ) 
Parameters
  • cursor_name

    This VARCHAR(256) value identifies the open cursor to describe.

Result set
Column name Data type Description
column_number INTEGER The ordinal position of the column described by this row, starting at 1.
name VARCHAR(128) The name of the column.
domain_id SMALLINT The data type of the column.
domain_name VARCHAR(128) The data type name of the column.
domain_name_with_size VARCHAR(160) The data type name, including size and precision (as used in CREATE TABLE or CAST functions).
width INTEGER The length of a string parameter, the precision of a numeric parameter, or the number of bytes of storage for any other data type.
scale INTEGER The number of digits after the decimal point for numeric data type columns, and zero for all other data types.
declared_width INTEGER The length of a string parameter, the precision of a numeric parameter, or the number of bytes of storage for any other data type.
user_type_id SMALLINT The user-defined data type if applicable, otherwise NULL.
user_type_name VARCHAR(128) The user-defined data type if applicable, otherwise NULL.
correlation_name VARCHAR(128) The correlation name associated with the expression if applicable, otherwise NULL.
base_table_id UNSIGNED INTEGER The table_id if the expression is a column, otherwise NULL.
base_column_id UNSIGNED INTEGER The column_id if the expression is a column, otherwise NULL.
base_owner_name VARCHAR(128) The owner name if the expression is a column, otherwise NULL.
base_table_name VARCHAR(128) The table name if the expression is a column, otherwise NULL.
base_column_name VARCHAR(128) The column name if the expression is a column, otherwise NULL.
nulls_allowed BIT The indicator whether the expression can be NULL (1).
is_autoincrement BIT An indicator whether the expression is an AUTOINCREMENT column (1).
is_key_column BIT An indicator whether the expression is part of a key for the result set (1). For more information, see the Remarks section below.
is_added_key_column BIT An indicator whether the expression is an added key column (1). For more information, see the Remarks section below.
Remarks

The sa_describe_cursor system procedure provides an API-independent mechanism for retrieving the description of the columns returned by the cursor. The system procedure can be useful when writing stored procedures that work with dynamic SQL.

The sa_describe_cursor system procedure can be used in a CALL statement or in the FROM clause of a SELECT statement.

cursor_name must refer to an open cursor in the current connection. Use the sa_list_cursors system procedure to get the list of open cursors for the connection.

Privileges

You must have EXECUTE privilege on the system procedure.

Side effects

None

Example

The following batch creates a cursor named myCursor on the Products table and then opens it. The sa_describe_cursor system procedure is used to describe the columns of the cursor. A result set containing 5 rows, one for each column, is produced.

BEGIN 
  DECLARE myCursor CURSOR FOR 
      SELECT ID, Name, Description, Color, Quantity FROM Products;
  OPEN myCursor;
  CALL sa_describe_cursor( 'myCursor' );
  CLOSE myCursor;
END