Alphabetical list of functions
354
♦
SQL/92 Transact-SQL extension.
♦
Sybase Compatible with Adaptive Server Enterprise.
"CASE expressions" on page 233
NUMBER function [Miscellaneous]
Generates numbers starting at 1 for each successive row in the results of the
query.
Deprecated feature
The NUMBER function is deprecated. It will not be supported in future
versions of Adaptive Server Anywhere.
NUMBER ( * )
The following statement returns a numbered list.
SELECT NUMBER( * )
FROM department
WHERE dept_id > 5
The NUMBER(*) function can be used to generate primary keys when using
the INSERT from SELECT statement (see "INSERT statement" on
page 554), although using AUTOINCREMENT is a preferred mechanism for
generating sequential primary keys.
$ For information on AUTOINCREMENT, see "CREATE TABLE
statement" on page 466.
You should not use NUMBER( * ) anywhere but in a select-list. If you do
use NUMBER( * ) rather than the preferred AUTOINCREMENT, you
should check your results carefully, as the behavior is not reliable in several
circumstances. For example, including the function in a WHERE clause or a
HAVING clause produces unpredictable results, and you should not include
NUMBER( * ) in a UNION operation.
In Embedded SQL, care should be exercised when using a cursor that
references a query containing a NUMBER(*) function. In particular, this
function returns negative numbers when a database cursor is positioned using
relative to the end of the cursor (an absolute position with a negative offset).
♦
SQL/92 Vendor extension.
♦
Sybase Not supported by Adaptive Server Enterprise.
Standards and
compatibility
See also
Function
Syntax
Examples
Usage
Standards and
compatibility