Tuesday, May 12, 2015

Oracle Function RPAD Explaination


RPAD

Definition:
In Oracle PL/SQL, RPAD is a built in function which pads the input string with extra characters from the right side. It accepts three arguments: the input string, the net length of the string including padding, and the character to be used for padded. Note that the third argument is optional. If it is not provided, Oracle will use blank spaces as the default padding character.

Example Syntax:


RPAD (input_string, length, padding_character)


Example Usage:

The SQL query below pads the string 'PSOUG' with the character 'X' up to 10 characters.

SQL> SELECT RPAD('9999',8,'0') FROM DUAL;

99990000


The SQL query shows that the padded length takes precedence over the actual length of the original string.

SQL> SELECT RPAD('YASSER', 3) FROM DUAL;

YAS

No comments:

Post a Comment