REPEAT¶
The REPEAT function in SQL is used to repeat a string for a specified number of times.
Syntax¶
Parameters¶
string: The string to be repeated.number: The number of times to repeat the string.
Return Value¶
The function returns a string which is the concatenation of the input string repeated the specified number of times.
Errors¶
- If the parameters are not in the correct format, a
TranslateError::FunctionArgsLengthNotMatchingerror will be returned. This function requires exactly two arguments. - If either
stringornumberare not string values, aEvaluateError::FunctionRequiresStringValueerror will be returned.
Examples¶
Consider a table Item created and filled with the following data:
You can use the REPEAT function to repeat the name values:
This will return:
The 'hello' string is repeated twice as specified by the second parameter to the REPEAT function.