PAD, RPAD, LPAD : CHAR VARCHAR2 Functions « PL SQL Data Types « Oracle PL/SQL Tutorial






Add characters to a string

RPAD is from the right side.

LPAD is from the left side.

v_tx:= lpad(string,length,extra string);
v_tx:= ltrim(string [,character]);
v_tx:= trim(LEADING|TRAILING|BOTH character from string);
SQL>
SQL> declare
  2      v1_tx VARCHAR2(20):='Hello!';
  3      v2_tx VARCHAR2(20);
  4      v3_tx VARCHAR2(20);
  5  begin
  6      v2_tx:= rpad(lpad(v1_tx,10,'*'),15,'*');
  7      DBMS_OUTPUT.put_line(v2_tx);
  8  end;
  9  /
****Hello!*****

PL/SQL procedure successfully completed.

SQL>








21.5.CHAR VARCHAR2 Functions
21.5.1.Useful character built-in functions
21.5.2.Compare char type value with blank space
21.5.3.Compare char type value with 'trim'
21.5.4.The most useful character specifications are
21.5.5.ASCII
21.5.6.SUBSTR
21.5.7.INSTR
21.5.8.Use the SUBSTR and INSTR at the same time.
21.5.9.REPLACE
21.5.10.TRANSLATE
21.5.11.PAD, RPAD, LPAD
21.5.12.TRIM
21.5.13.Extending your options with regular expressions
21.5.14.A Better Routine to Check Social Security Numbers