11.6. String Concatenation

The concatenation operator is:

||

This operator concatenates strings, but you can concatenate other types. PL/SQL does implicit conversion, such as converting a number and date type variable to a string. This enables statements to concatenate various types, but only if the concatenated item converts to a string.

DECLARE
    professor_name VARCHAR2(100) := 'Professor Smith';
    hire_date      DATE          := SYSDATE;
    dalary         NUMBER(7,2)   := 10100.50;
    str            VARCHAR2(2000);
BEGIN
    str := professor_name|| ' was hired on '||
           hire_date ||' with a salary of '||
           salary||' per month. ';
    dbms_output.put_line(str);
END;

You precede each single quote that is part of the string with a quote. For example, your string needs to include a single quote because ...

Get Programming Oracle® Triggers and Stored Procedures, Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.