declare
v_date date;begin
v_date:=date'2011-6-1';loop
  execute immediate'
  insert into table1
  select a.aa ,b.bb
  from table2@yy a,table3@yy b
  where  b.bb=a.dd and a.cc=v_date
    and a.ee = ''0''
  ';
  v_date:=v_date+1;
  exit when v_date > date'2011-6-30';
end loop;
commit;
end;
报错的地方是 v_date invalid identifier

解决方案 »

  1.   


    declare
    v_date date;begin
    v_date:=date'2011-6-1';loop
      execute immediate'
      insert into table1
      select a.aa ,b.bb
      from table2@yy a,table3@yy b
      where b.bb=a.dd and a.cc= ''' || v_date || '''
      and a.ee = ''0''
      ';
      v_date:=v_date+1;
      exit when v_date > date'2011-6-30';
    end loop;
    commit;
    end; 
      

  2.   

    Oracle中日期转换是用to_date()
    你的语法不对 是MSSQL的语法
      

  3.   

    还有就是v_date是变量 参数传递要拼接
      

  4.   


    能说一下为什么要加那么多引号么-.-我对plsql还在摸索阶段...谢谢
      

  5.   

    哦Oracle可以v_date:=date'2011-6-1';
    呵呵。。
      

  6.   

    引号这东西  要说有啥规则  那太麻烦   最好的办法 就是你把生成的字符串  插到一个table里看下  就知道为啥加那么多引号了·   哈
      

  7.   


    这个不需要啥教程啊~~  只要能把字符串拼出来就好了~   插到一个测试table的栏位里   看看是否正常  不正常再调整引号的数量 ·   调几次就知道了