← PL/SQL Topics

String & Data Functions

Explain the TRIM, LPAD and RPAD string functions in PL/SQL

TRIM, LPAD, RPAD

Oracle Fusion / EBS · Technical · PL/SQL

GeneralHigh confidence

TRIM strips leading/trailing characters; LPAD/RPAD pad a string out to a fixed length.

Grounded in: Curated Oracle knowledge layer — PL/SQL

How it works

TRIM removes leading and/or trailing characters — spaces by default, or a specific character via TRIM(LEADING/TRAILING/BOTH 'x' FROM string). LPAD and RPAD pad a string out to a fixed total length by repeating a pad string on the left or right respectively — the standard way to zero-pad an ID or align fixed-width report output.

How it works
SELECT
  TRIM('  Oracle  ')             AS trimmed,
  LPAD(TO_CHAR(42), 6, '0')      AS zero_padded,
  RPAD('AR', 10, '.')            AS dot_padded
FROM dual;
-- trimmed      => 'Oracle'
-- zero_padded  => '000042'
-- dot_padded   => 'AR........'

Related Questions

Have a follow-up, or a different question?

Continue in Ask Oracle AI