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

NORMALIZE

Syntax

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

Purpose

The NORMALIZE SQL function normalises a file path for use as a filename by replacing all characters invalid for use in a file path by an underscore. Also, non-ASCII characters are replaced by an underscore. The resulting file path is simplified by various operations such as de-duplication of consecutive whitespace and underscore characters.

Parameters:

  • Original file path (varchar2): path of the file.
  • Maximum file name length (int32): length in characters into which the normalised file name must fit.
  • Allow path separator (boolean): whether to allow the path separators \ and / in the normalised file name. When not, occurrences are replaced by an underscore.

Returns: a normalised file path.

Examples

The following example normalizes a file path into 16 characters, keeping the path separator:

select normalize('abcdefghijklm%nopqrstuvwxyz', 16, true)

----------------
abcdefghijklm%no

The following example normalizes the same file path into 16 characters, replacing the path separator by an underscore:

select normalize('abcdefghijklm/nopqrstuvwxyz', 16, false)

----------------
abcdefghijklm_no