Partager via


TOSTRING - Langage de requête dans Cosmos DB (dans Azure et Fabric)

La TOSTRING fonction retourne une représentation sous forme de chaîne d’une valeur.

Fonction système Azure Cosmos DB pour NoSQL qui retourne une valeur convertie en chaîne.

Syntaxe

TOSTRING(<expr>)

Arguments

Descriptif
expr Toute expression.

Types de retour

Retourne une expression de chaîne.

Examples

Cette section contient des exemples d’utilisation de cette construction de langage de requête.

Convertir des valeurs en chaîne

Dans cet exemple, la TOSTRING fonction est utilisée pour convertir plusieurs valeurs scalaires et d’objets en chaîne.

SELECT VALUE {
  integerToString: TOSTRING(125),
  floatToString: TOSTRING(0.1234),
  booleanToString: TOSTRING(false),
  arrayToString: TOSTRING([ 1, 2, 3 ]),
  objectToString: TOSTRING({ "department": "Bicycles" }),
  stringToString: TOSTRING("Hello World"),
  undefinedToString: TOSTRING(undefined),
  notANumberToString: TOSTRING(NaN),
  infinityToString: TOSTRING(Infinity)
}
[
  {
    "integerToString": "125",
    "floatToString": "0.1234",
    "booleanToString": "false",
    "arrayToString": "[1,2,3]",
    "objectToString": "{\"department\":\"Bicycles\"}",
    "stringToString": "Hello World",
    "notANumberToString": "NaN",
    "infinityToString": "Infinity"
  }
]

Remarques

  • Cette fonction n’utilise pas l’index.