SQL/MX 3.1 Reference Manual (H06.23+, J06.12+)
SQL/MX Functions and Expressions
HP NonStop SQL/MX Release 3.1 Reference Manual—663850-001
9-146
Examples of RPAD
•
The following RPAD function returns a string of seven characters 'kite '. The
string 'kite' is right-padded with three spaces.
RPAD('kite', 7)
•
The following RPAD function returns a string of eight characters 'kite0000'. The
string 'kite' is right-padded with four pad-characters '0'.
RPAD('kite', 8, '0')
•
The following RPAD function returns a string of 14 characters 'go fly a kitez'.
The string 'go fly a kite' is right-padded with one pad-character 'z'.
RPAD('go fly a kite', 14, 'z')
•
The following RPAD function returns a string of 17 characters
'kitegoflygoflygof'. The string 'kite' is right-padded with string 'gofly' such
that the result string has 17 characters.
RPAD('kite', 17, 'gofly' )
The default behavior of the RPAD function and the corresponding examples are
described below.
The count specifies the number of characters to be replaced. The count must be
less than or equal to the length of the character-expr. If count is smaller than or
equal to the length of the character-expr, the rightmost count characters of the
character-expr are replaced with the padding characters or string. If count is
greater than the length of the character-expr, an error is returned.
•
The following RPAD function replaces two rightmost characters in the string 'kite'
with spaces and returns 'ki ':
RPAD('kite', 2)
•
The following RPAD function replaces two rightmost characters 'Jo' with the string
'John,' twice and returns 'go fly a kite John,John,':
RPAD('go fly a kite Jo', 2, 'John,')
•
The following RPAD function replaces 13 rightmost characters in the string 'go
fly a kite' with character 'z' and returns 'zzzzzzzzzzzzz':
RPAD('go fly a kite', 13, 'z')
•
The following RPAD functions return an error because the count is greater than
the string length:
RPAD('kite', 7)
RPAD('kite', 8, '0')
RPAD('go fly a kite', 14, 'z')
RPAD('kite', 17, 'gofly' )










