Checking the cursor status

Adaptive Server returns a status value after each fetch. You can access the value through the global variable @@sqlstatus. Table 18-1lists @@sqlstatus values and their meanings:

Table 18-1: @@sqlstatus values

Value

Meaning

0

Indicates successful completion of the fetch statement.

1

Indicates that the fetch statement resulted in an error.

2

Indicates that there is no more data in the result set. This warning can occur if the current cursor position is on the last row in the result set and the client submits a fetch statement for that cursor.

The following example determines the @@sqlstatus for the currently open authors_crsr cursor:

select @@sqlstatus
---------
        0
 
(1 row affected)

Only a fetch statement can set @@sqlstatus. Other statements have no effect on @@sqlstatus.