共用方式為


IS_STRING - Cosmos DB 中的查詢語言 (在 Azure 和 Fabric 中)

IS_STRING 式會傳回布林值,指出指定運算式的類型是否為字串。

適用於 NoSQL 的 Azure Cosmos DB 系統函式,如果指定運算式的類型是字串,則會傳回 true。

語法

IS_STRING(<expr>)

Arguments

Description
expr 任何表達式。

傳回類型

傳回布林運算式。

範例

本節包含如何使用此查詢語言建構的範例。

檢查值是否為字串

在此範例中,函 IS_STRING 式用於檢查各種值,以查看它們是否為字串。

SELECT VALUE {
  isBooleanAString: IS_STRING(true),
  isNumberAString: IS_STRING(1),
  isStringAString: IS_STRING("value"),
  isArrayAString: IS_STRING([ "green", "red", "yellow" ]),
  isNullAString: IS_STRING(null),
  isObjectAString: IS_STRING({ "name": "Tecozow coat" }),
  isObjectStringPropertyAString: IS_STRING({ "name": "Tecozow coat" }.name),
  isObjectBooleanPropertyAString: IS_STRING({ "onSale": false }.onSale),
  isUndefinedAString: IS_STRING({}.category)
}
[
  {
    "isBooleanAString": false,
    "isNumberAString": false,
    "isStringAString": true,
    "isArrayAString": false,
    "isNullAString": false,
    "isObjectAString": false,
    "isObjectStringPropertyAString": true,
    "isObjectBooleanPropertyAString": false,
    "isUndefinedAString": false
  }
]

備註

  • 此功能受益於範圍索引的使用。 如需詳細資訊,請參閱 範圍索引