SQL>
SQL> SET SERVEROUTPUT ON --for DBMS_OUTPUT.PUT_LINE.
SQL> SET ECHO ON
SQL> DECLARE
2 employee_name_c CHAR(32);
3 employee_name_v VARCHAR2(32);
4 BEGIN
5 --Assign the same value to each string.
6 employee_name_c := 'James Gennick';
7 employee_name_v := 'James Gennick';
8
9 --Test the strings for equality.
10
11 IF employee_name_c = employee_name_v THEN
12 DBMS_OUTPUT.PUT_LINE('The names are the same');
13 ELSE
14 DBMS_OUTPUT.PUT_LINE('The names are NOT the same');
15 END IF;
16 END;
17 /
The names are NOT the same
PL/SQL procedure successfully completed.
This occurred because the CHAR string contains a number of trailing spaces, whereas the VARCHAR2 string does not.