max后应为number字段,而不是varchar等字符型字段。

解决方案 »

  1.   

    try
    select max(nvl(HSTime,sysdate)) INTO LastDay FROM SA.Sys_DepotDayHead;
    or 
    select max(nvl(HSTime,otherdatetypevalue)) INTO LastDay FROM SA.Sys_DepotDayHead;because 0 is not a date type;
      

  2.   

    试试这个
    select max(nvl(HSTime,'1900-01-01') INTO LastDay FROM SA.Sys_DepotDayHead;
    要是不行,下面的肯定行
    select max(nvl(HSTime,to_date('1900-01-01','yyyy-mm-dd')) INTO LastDay FROM SA.Sys_DepotDayHead;
      

  3.   

    select max(HSTime) INTO LastDay FROM SA.Sys_DepotDayHead
    exception
    when not_data_found then
    LastDay:=...;
    end;
      

  4.   

    select max(nvl(HSTime,sysdate)) from SA.Sys_DepotDayHead
      

  5.   

    select max(nvl(HSTime,0)) INTO LastDay FROM SA.Sys_DepotDayHead;
    楼主为什么要这么写呀?
    select max(HSTime) INTO LastDay FROM SA.Sys_DepotDayHead;
    这样就好了呀?!
    然后判断 LastDay is null ? 就好了呀!