日期:2014-05-16  浏览次数:20478 次

Oracle 获得最大日期
-- Created on 2010/06/08 by NAN
declare
  -- Local variables here
  TYPE t_test IS TABLE OF DATE INDEX BY BINARY_INTEGER;
  v_test t_test;
  v_date DATE;
BEGIN
  -- Test statements here
  v_test(1) := '20020202';
  v_test(2) := '20090202';
  v_test(3) := '20100202';
  FOR i IN 1 ..v_test.count LOOP
      IF v_date IS NULL THEN
         v_date := v_test( 1);
      END IF ;
     
      IF v_date < v_test(i) THEN
         v_date := v_test(i);
      END IF ;
  END LOOP;
 
  dbms_output.put_line(v_date);
 
  EXCEPTION
      WHEN OTHERS THEN
           dbms_output.put_line( Sqlerrm);
end;