7-1. Concatenating Strings
Problem
You have two or more text strings, or variables containing strings, that you want to combine.
Solution
Use the concatenation operator to append the strings. In the following example, you can see that two variables are concatenated to a string of text to form a single string of text:
DECLARE
CURSOR emp_cur IS
SELECT employee_id, first_name, last_name
FROM EMPLOYEES
WHERE HIRE_DATE > TO_DATE('01/01/2000','MM/DD/YYYY');
emp_rec emp_cur%ROWTYPE;
emp_string VARCHAR2(150);
BEGIN
DBMS_OUTPUT.PUT_LINE('EMPLOYEES HIRED AFTER 01/01/2000');
DBMS_OUTPUT.PUT_LINE('================================');
FOR emp_rec IN emp_cur LOOP
emp_string := emp_rec.first_name || ' ' || emp_rec.last_name ...
Get Oracle and PL/SQL Recipes: A Problem-Solution Approach 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.