pl-sql它不能比较两个字符串?为什么

时间:2017-10-10 17:23:49

标签: oracle plsql

declare 
  v_date varchar2(15);
begin 
  v_date := to_char(sysdate, 'DAY');
  if upper(v_date) = to_char('TUESDAY') then
     dbms_output.put_line('Today is Tuesday');
  else 
     dbms_output.put_line('Today is not tuesday'|| upper(v_date) );
  end if ;
end; 

1 个答案:

答案 0 :(得分:1)

请调整你从to_char获得的值,然后你应该得到正确的结果

declare 
  v_date varchar2(15);
begin 
  v_date := to_char(sysdate, 'DAY');
  if trim(v_date) = 'TUESDAY' then
     dbms_output.put_line('Today is Tuesday');
  else 
     dbms_output.put_line('Today is not tuesday '|| v_date );
  end if ;
end;