Documentazione Invantiveparte di invantive cloud
Forum di supporto InvantiveAccedi / Registrati

TO_BOOLEAN

Sintassi

%%{init: {
  'theme': 'base',
  'flowchart': { 'padding': '7', 'nodeSpacing': '20', 'rankSpacing': '20' },
  'themeVariables': {
    'fontSize': '11px',
    'fontFamily': 'Arial'
  }
}}%%
flowchart LR
    Start((START)) --> TO_BOOLEAN[TO_BOOLEAN]:::quoted
    TO_BOOLEAN --> End((END))

Scopo

La funzione SQL TO_BOOLEAN converte un valore in un boolean. I valori non convertibili generano un errore; per evitare tale errore, verificare prima il valore utilizzando IS_BOOLEAN.

Per i numeri, 0 è considerato false e tutti gli altri valori true. Tutti gli datetime sono false. Per i testi, sono considerati true i seguenti: 'true', 't', 'yes', 'y', 'on', '1', 'True', 'TRUE', 'T', 'YES', 'Y' e 'ON'. False are 'false', 'f', 'no', 'n', 'off', '0', 'False', 'FALSE', 'F', 'NO', 'N' and 'OFF'.

Parametri:

  • Input (ANY): valore da convertire.

Restituisce: l’input convertito in un boolean.

Esempi

L'esempio seguente converte il testo 'true' in boolean:

select to_boolean('true')

----------------
true

L'esempio seguente genera un errore:

select to_boolean('tr')

itgendid068: Invalid boolean value 'tr'.