This topic describes how to use the string function REPEAT in Realtime Compute.

Syntax

VARCHAR REPEAT(VARCHAR str, INT n)

Input parameters

Parameter Data type Description
str VARCHAR The string that you want to repeat.
n INT The number of times to repeat the string.

Description

Repeats a string a specified number of times and returns a new string. If the str parameter is null, null is returned. If the n parameter is 0 or negative, an empty string is returned.

Example

  • Test data
    str (VARCHAR) n (INT)
    J 9
    Hello 2
    Hello -9
    null 9
  • Test statements
    SELECT  REPEAT(str,n) as var1
    FROM T1;        
  • Test results
    var1 (VARCHAR)
    JJJJJJJJJ
    HelloHello
    null
    null