invantive documentationpart of invantive cloud
Invantive Support ForumsLog In / Sign Up

SPLIT_PART

Syntax

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

Purpose

The SPLIT_PART SQL function splits a text on a delimiter and returns the requested part, similar to the split_part function of PostgreSQL and Amazon Redshift.

See also TO_ARRAY.

Parameters:

  • Text (varchar2): the text to split.
  • Delimiter (varchar2): the delimiter to split the text on.
  • Part number (int32): the part to return, with 1 being the first part.

Returns: the requested part as varchar2. Returns null when the text or delimiter is null or empty, when the part number is less than 1 or when the part number exceeds the number of parts.

Examples

The following example retrieves the second part of a,b,c:

select split_part('a,b,c', ',', 2)

-------------------
b

The following example retrieves the fifth part of a,b,c; the output is empty since there are only three parts:

select split_part('a,b,c', ',', 5)

-------------------