Dela via


2.2.7.6 DONE

Token Stream Name:

 DONE

Token Stream Function:

Indicates the completion status of a SQL statement.

Token Stream Comments

  • The token value is 0xFD.

  • This token is used to indicate the completion of a SQL statement. As multiple SQL statements can be sent to the server in a single SQL batch, multiple DONE tokens can be generated. In this case, all but the final DONE token has a Status value with DONE_MORE bit set (details follow).

  • A DONE token is returned for each SQL statement in the SQL batch except variable declarations.

  • For execution of SQL statements within stored procedures, DONEPROC and DONEINPROC tokens are used in place of DONE tokens.

Token Stream-Specific Rules:

 TokenType        =   BYTE
 Status           =   USHORT
 CurCmd           =   USHORT
 DoneRowCount     =   LONG / ULONGLONG;  (Changed to ULONGLONG in TDS 7.2)

The type of the DoneRowCount element depends on the version of TDS.

Token Stream Definition:

 DONE             =   TokenType
                      Status
                      CurCmd
                      DoneRowCount

Token Stream Parameter Details:

Parameter

Description

TokenType

DONE_TOKEN

Status

The Status field MUST be a bitwise 'OR' of the following:

  • 0x00: DONE_FINAL. This DONE is the final DONE in the request.

  • 0x1: DONE_MORE. This DONE message is not the final DONE message in the response. Subsequent data streams to follow.

  • 0x2: DONE_ERROR. An error occurred on the current SQL statement. A preceding ERROR token SHOULD be sent when this bit is set.

  • 0x4: DONE_INXACT. A transaction is in progress.<44>

  • 0x10: DONE_COUNT. The DoneRowCount value is valid. This is used to distinguish between a valid value of 0 for DoneRowCount or just an initialized variable.

  • 0x20: DONE_ATTN. The DONE message is a server acknowledgement of a client ATTENTION message.

  • 0x100: DONE_SRVERROR. Used in place of DONE_ERROR when an error occurred on the current SQL statement, which is severe enough to require the result set, if any, to be discarded.

CurCmd

The token of the current SQL statement. The token value is provided and controlled by the application layer, which utilizes TDS. The TDS layer does not evaluate the value.

DoneRowCount

The count of rows that were affected by the SQL statement. The value of DoneRowCount is valid if the value of Status includes DONE_COUNT.<45>