54.1 FORMAT Function

This function returns a formatted string with substitutions applied.

Returns p_message after replacing each <n>th occurrence of %s with p<n> and each occurrence of %<n> with p<n>. If p_max_length is not null, substr(p<n>,1,p_arg_max_length) is used instead of p<n>.

Use %% in p_message to emit a single % character. Use %n to emit a newline.

Syntax

APEX_STRING.FORMAT (
     p_message    IN VARCHAR2,
     p0           IN VARCHAR2     DEFAULT NULL,
     p1           IN VARCHAR2     DEFAULT NULL,
     p2           IN VARCHAR2     DEFAULT NULL,
     p3           IN VARCHAR2     DEFAULT NULL,
     p4           IN VARCHAR2     DEFAULT NULL,
     p5           IN VARCHAR2     DEFAULT NULL,
     p6           IN VARCHAR2     DEFAULT NULL,
     p7           IN VARCHAR2     DEFAULT NULL,
     p8           IN VARCHAR2     DEFAULT NULL,
     p9           IN VARCHAR2     DEFAULT NULL,
     p10          IN VARCHAR2     DEFAULT NULL,
     p11          IN VARCHAR2     DEFAULT NULL,
     p12          IN VARCHAR2     DEFAULT NULL,
     p13          IN VARCHAR2     DEFAULT NULL,
     p14          IN VARCHAR2     DEFAULT NULL,
     p15          IN VARCHAR2     DEFAULT NULL,
     p16          IN VARCHAR2     DEFAULT NULL,
     p17          IN VARCHAR2     DEFAULT NULL,
     p18          IN VARCHAR2     DEFAULT NULL,
     p19          IN VARCHAR2     DEFAULT NULL,
     p_max_length IN PLS_INTEGER  DEFAULT 1000,
     p_prefix     IN VARCHAR2     DEFAULT NULL )
     return VARCHAR2

Parameters

Parameters Description
p_message Message string with substitution placeholders.
p0-p19 Substitution parameters.
p_max_length If not null (default is 1000), cap each p<n> at p_max_length characters.
p_prefix If set, remove leading white space and the given prefix from each line. This parameter can be used to simplify the formatting of indented multi-line text.

Example 1

APEX_STRING.FORMAT('%s+%s=%s', 1, 2, 'three')
-> 1+2=three

APEX_STRING.FORMAT('%1+%2=%0', 'three', 1, 2)
-> 1+2=three

Example 2

APEX_STRING.FORMAT (
    q'!BEGIN
      !    IF NOT VALID THEN
      !        apex_debug.info('validation failed');
      !    END IF;
      !END;!',
    p_prefix => '!' )
 -> BEGIN
        IF NOT VALID THEN
            apex_debug.info('validation failed');
        END IF;
    END;