Skip to main content
← PL/SQL Topics

String & Data Functions

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

TRIM, LPAD, RPAD

ExplanationOracle Fusion / EBS · Technical · PL/SQLHigh confidenceGenerated

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

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

GroundingGenerated

Model-generated, grounded against the curated knowledge layer. Check specifics against your instance.

Have a follow-up, or a different question?

Continue in Ask Oracle AI