9.1 結果集類別

所有資料庫作業都會傳回結果。傳回的結果類型取決於執行的作業。下表概述了不同的結果類型。

表 9.1 結果類別及其提供的資訊

結果類別

傳回者

提供

Result

add().execute()insert().execute()modify().execute()update().execute()remove().execute()delete().execute()

受作業影響的資料列數、自動產生的文件 ID、最後一個自動產生的 AUTO INCREMENT 資料行值,或警告,具體取決於傳回 Result 的作業。

SqlResult

session.sql().execute()

受作業影響的資料列數、自動產生的文件 ID、最後一個自動產生的 AUTO INCREMENT 資料行值、警告或擷取的資料集,具體取決於傳回 SqlResult 的作業。

DocResult

find().execute()

擷取的資料集

RowResult

select.execute()

擷取的資料集


以下類別圖提供結果類別及其函式的基本概觀。

圖 9.1 結果類別

In the following functions, square brackets indicate a list of items. This can be any appropriate list type in the target language (an array, a collection, and so on). The BaseResults class contains the following functions: getWarnings(): Warning[] and getWarningsCount(): int, which are diagnostics functions. The Result class contains the following functions: getAffectedItemsCount(): int, getAutoIncrementValue(): int, getGeneratedIds(): String[], which are data change information functions. The DocResult class contains the following functions: fetchAll(): Document[] and fetchOne(): Document, which are document access functions. The RowResult class contains the following functions: fetchAll(): Row[], fetchOne(): Row, getColumns(): Column[], and nextResult(): boolean. The SqlResult class contains the following functions: hasData(): boolean, getAffectedItemsCount(): int, and getAutoIncrementValue(): int.