set serveroutput on;
declare
  v_last_time   date;
  v_cardnum     cardmast.cardnum%type;  
  v_table_name  audtrail.table_name%type;
  v_fid_name    audtrail.fld_name%type;
  v_index_1     audtrail.index_1%type;
  v_index_2     audtrail.index_2%type;
  v_index_3     audtrail.index_3%type;
  v_index_4     audtrail.index_4%type;
  v_before_val  audtrail.before_val%type;
  v_after_val   audtrail.after_val%type;
  v_change_data audtrail.change_date%type;
  v_change_time audtrail.change_time%type;
  v_fld_type    audtrail.fld_type%type;
  v_comments    audtrail.comments%type;
  c_user        audtrail.user_id%type;  
  cursor card_cursor is 
  select cardnum from cardmast,temp_cif where cardmast.cif=temp_cif.cif;
  
  cursor aud_cursor(v_time date,v_index audtrail.index_1%type) is 
  select *  from audtrail where index_1 = v_index and change_date = v_time;
 begin
  select  last_eod_date into v_last_time from eod_ctrl;
 dbms_output.put_line('ok---------'||v_last_time);   
   open  card_cursor;
  begin
     fetch next from card_cursor into @v_last_time;
     while(@@fetch_status = 0)       
        open aud_cursor;
         fetch next from aud_cursor into v_table_name,v_fid_name,v_index_1,v_index_2,v_index_3,v_index_4,v_before_val,v_after_val,
          c_user,v_change_data,v_change_time,v_fld_type,v_comments;
          while(@@fetch_status = 0)
          begin
           fetch next from aud_cursor into v_table_name,v_fid_name,v_index_1,v_index_2,v_index_3,v_index_4,v_before_val,v_after_val,
          c_user,v_change_data,v_change_time,v_fld_type,v_comments;
        end;
        close aud_cursor;
        deallocate aud_cursor;
        fetch next from card_cursor into @v_last_time;
      end;
   close card_cursor;
   deallocate card_cursor;
  exception
   when no_data_found then
    dbms_output.put_line('the audtrail!');
   when others then
      dbms_output.put_line('no reason');
end;
/
报错
     fetch next from card_cursor into @v_last_time;
                *
ERROR at line 27:
ORA-06550: line 27, column 17:
PLS-00103: Encountered the symbol "FROM" when expecting one of the following:
. into bulk
请问怎么解决,想了两天了,未解决~

解决方案 »

  1.   

    1>fetch next from card_cursor into @v_last_time;改成fetch card_cursor into @v_last_time;2>:@@fetch_status = 0改成card_cursor%found3>:@@是别的数据库的语法吧。。
      

  2.   


    declare
      v_last_time date;
      v_cardnum cardmast.cardnum%type;   
      v_table_name audtrail.table_name%type;
      v_fid_name audtrail.fld_name%type;
      v_index_1 audtrail.index_1%type;
      v_index_2 audtrail.index_2%type;
      v_index_3 audtrail.index_3%type;
      v_index_4 audtrail.index_4%type;
      v_before_val audtrail.before_val%type;
      v_after_val audtrail.after_val%type;
      v_change_data audtrail.change_date%type;
      v_change_time audtrail.change_time%type;
      v_fld_type audtrail.fld_type%type;
      v_comments audtrail.comments%type;
      c_user audtrail.user_id%type;   
      cursor card_cursor is  select cardnum from cardmast,temp_cif where cardmast.cif=temp_cif.cif;
       
    cursor aud_cursor(v_time date,v_index audtrail.index_1%type) is  select * from audtrail where index_1 = v_index and change_date = v_time;
     begin
      select last_eod_date into v_last_time from eod_ctrl;
    dbms_output.put_line('ok---------'||v_last_time);   
      open card_cursor;  fetch  card_cursor into v_last_time;
    ---v_time,v_index的值呢?
      while   card_cursor%found loop
      open aud_cursor(v_time,v_index);
      fetch  aud_cursor(v_time,v_index) into v_table_name,v_fid_name,v_index_1,v_index_2,v_index_3,v_index_4,v_before_val,v_after_val,
      c_user,v_change_data,v_change_time,v_fld_type,v_comments;
      while   aud_cursor%found loop  fetch  aud_cursor into v_table_name,v_fid_name,v_index_1,v_index_2,v_index_3,v_index_4,v_before_val,v_after_val,
      c_user,v_change_data,v_change_time,v_fld_type,v_comments;  
      end loop;
      close aud_cursor;
      fetch  card_cursor into v_last_time;
      end loop;
      close card_cursor;  exception
      when no_data_found then
    dbms_output.put_line('the audtrail!');
      when others then
      dbms_output.put_line('no reason');
    end;
      

  3.   


    问一下,date类型的比较可以用=号吗?还是有相应的函数
      

  4.   

    --我错了,格式可以不一样
    DECLARE
     date1 DATE;
     date2 DATE;
    BEGIN
         date1:=To_Date('20101230','yyyymmdd');
         date2:=To_Date('2010-12-30','yyyy-mm-dd');
         IF date1=date2 THEN 
         Dbms_Output.put_line('date1 = date2');
         ELSE
         Dbms_Output.put_line('date1 != date2');     END IF;
    END;     PL/SQL block, executed in 0 sec.
         date1 = date2                   
         Total execution time 0 sec.     
      

  5.   

    --注意 前后比较的两个日期至少要是同一天或者是同一个时间格式,
    DECLARE
     date1 DATE;
     date2 DATE;
    BEGIN
         date1:=To_Date('2010-12-30 ','yyyy-mm-dd');      --格式到天
         date2:=To_Date('2010-12-30 14:22:22','yyyy-mm-dd hh24:mi:ss');   --格式到秒 
         IF date1=date2 THEN 
          Dbms_Output.put_line('date1 = date2');
         ELSE
          Dbms_Output.put_line('date1 != date2');     END IF;
    END;     PL/SQL block, executed in 0 sec.
         date1 != date2                  
         Total execution time 0.016 sec. 
      

  6.   

    可以的 你是比较什么 ?
    单纯的日期 trunc(dt1)=trunc(dt2)