When comparing CHAR strings against VARCHAR2 strings, use the rtrim function to eliminate trailing spaces : VARCHAR2 « PL SQL Data Types « Oracle PL/SQL Tutorial
SQL>
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 rtrim(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 the same
PL/SQL procedure successfully completed.
SQL>