+ 1
Comparing CHAR with VARCHAR2
Why can't I compare data types v_day1 CHAR(10) against v_day2 VARCHAR2(10) when I've assigned to them today's day of the week using to_char(sysdate, 'day'); ? Another scenario is also writing a block comparing v_day2 with 'tuesday'... As in if v_day2 = 'tuesday' then /* output some text */. When I do this test with v_day1 which is CHAR(10) instead of v_day2 VARCHAR2(10) then the test passes with today being tuesday. Why is this? Even when I've assigned the values in the same way. Thanks in advance!
2 Antworten
+ 3
No experience with PL/SQL, but I guess these (from a simple web search) would be related perhaps:
http://www.java2s.com/Tutorial/Oracle/0420__PL-SQL-Data-Types/WhencomparingCHARstringsagainstVARCHAR2stringsusethertrimfunctiontoeliminatetrailingspaces.htm
https://docs.oracle.com/cd/A97630_01/appdev.920/a96624/b_char.htm
Hth, cmiiw
+ 1
Thanks the rtrim worked but I still don't see what goes wrong when you are using the same assignment method to get the current day, as in why would it give you the name of the day with white spaces.