用delphi的datadump工具呀,先建立excel以及ORACLE的数据源,之后按照DATADUMP工具的提示操作就OK拉

解决方案 »

  1.   

    http://www.oradb.net/tran/excel2ora.htm
      

  2.   

    很抱歉,我可不会了“用写的,NOKIA3108”,呵,没有作过
      

  3.   

    我想知道如何用delphi语句写出来?
      

  4.   

    ///数据源为Excel文件的数据导入
      //显示MS-Excel的运行过程
      If kzm='.XLS' then begin
        Edit2.Visible:=False;
        Edit_M.Visible:=False;
        Label13.Visible:=False;
        Label17.Visible:=False;    //建一个临时Excel,用来记录错误信息      aSheet_Error:=CreateOleObject('Excel.Application') ;
          aSheet_Error.Caption:='应用程序调用Microsoft Excel';
          //aSheet_Error.Visible:=True;
          aSheet_Error.WorkBooks.Add;    {aSheet:=CreateOleObject('Excel.Application') ;
        aSheet.Caption:='应用程序调用Microsoft Excel';
        //aSheet.Visible:=True;
        //aSheet.WorkBooks.Add;
        aSheet.WorkBooks.Open(SelectFileName);
       // aSheet.WorkSheets[Copy(SQLString,Pos('From ',SQLString)+Length('From '),Length(SQLString)-Pos('From ',SQLString)+1-Length('From '))].Activate:=True;
        }
        //根据输入的时间段确定需要导入的记录
        J:=-1;        If Pos('D1002',SQLString)<>0 Then J:=1 ELSE        If Pos('D1003',SQLString)<>0 Then J:=1 ELSE
     begin
            StatDate:=StartDate_Edit_Y.Text+StartDate_Edit_M.Text;
            EndDate:=EndDate_Edit_Y.Text+EndDate_Edit_M.Text;
          end else
          begin
            StatDate:=StartDate_Edit_Y.Text+'-'+StartDate_Edit_M.Text+'-'+Start_Edit_D.Text;
            EndDate:=EndDate_Edit_Y.Text+'-'+EndDate_Edit_M.Text+'-'+End_Edit_D.Text;
          end;
          Count1:=0;
          Count2:=0;
     for i:=1 to Count do
            begin
              Str:=aSheet.Cells[i,J].Value;
              if length(str)<7 then
              begin
              if (Str<StatDate) Then Count1:=Count1+1;
              if (Str>EndDate) Then Count2:=Count2+1;
              end
              else
              begin
              str1:=strtodatetime(str);
              StatDate1:=strtodatetime(statdate);
              EndDate1:=strtodatetime(endDate);
              if (Str1<StatDate1) Then Count1:=Count1+1;
              if (Str1>EndDate1) Then Count2:=Count2+1;
              end;
            //  if count1>0 then showmessage('aa');
            //  if count2>0 then showmessage('bb');
            end;
            Count:=Count-(Count1+Count2);
          end;    //showmessage(aSheet.Cells[1,5].Value);
        ProgressBar1.Min:=0;
        ProgressBar1.Position:=0;
        ProgressBar1.Max:=count;
        //i:=1;
        j:=(count div 2)+Count1;
         //添加记录
        //创建线程对象
        FMyFirstThread:=TMyFirstThread.Create(True);
        FMySecondThread:=TMyFirstThread.Create(True);
        FMyFirstThread.SetRange(Count1+1,J);
        FMySecondThread.SetRange(J+1,Count+Count1);    FMyFirstThread.FreeOnTerminate:=True;
        FMyFirstThread.OnTerminate:=MyFirstThreadTerminate;    FMySecondThread.FreeOnTerminate:=True;
        FMySecondThread.OnTerminate:=MySecondThreadTerminate;    Randomize;
        //启动线程
        FMyFirstThread.Resume;
        FMySecondThread.Resume;
     
        //label1.Caption:='共导入'+floattostr(count)+'条记录';    adoquery1.Close;
        exit_Button.Enabled:=True;
      end 
    function TForm_HTGL.Statistic(TableName:String;Index:Integer):Integer;
    var
      str,DateStr,MaxDate,MinDate:String;
      I,J:Integer;
      DateStr1,MaxDate1,MinDate1:Tdatetime;
      yyyy,mm,dd,yyyy1,mm1,dd1:word;
    begin
          J:=Index;
          Count:=0;
          ProgressBar2.Min:=COUNT;
          aSheet.WorkSheets[TableName].Activate;
          DateStr:='';
          If J<>-1 Then
          begin
            MinDate:= aSheet.Cells[1,J+1].Value;
            maxDate:=mindate;
            Label6.Visible:=True;
            DateRange_Edit_S.Visible:=True;
          end else      begin
            Label6.Visible:=False;
            DateRange_Edit_S.Visible:=False;
          end;
          for i:=1 to aSheet.Rows.Count do
          begin
             str:='';
             str:=aSheet.Cells[i,1].Value;         if str='' then break;
             count:=count+1;
             ProgressBar2.Position:=COUNT;         If J=-1 Then continue;
             DateStr:= aSheet.Cells[i,J+1].Value;     //    DateStr1:=STRTODATETIME(DateStr);
         //    MinDate1:=STRTODATETIME(minDate);     //    maxDate1:=STRTODATETIME(maxDate);
             /////////
           if length(DateStr)<7 then
          begin
             If MaxDate<DateStr Then MaxDate:=DateStr;
             if MinDate>DateStr Then MinDate:=DateStr;
          end
          else
          begin
             DateStr1:=STRTODATETIME(DateStr);
             MinDate1:=STRTODATETIME(minDate);
             maxDate1:=STRTODATETIME(maxDate);
            If MaxDate1<DateStr1 Then MaxDate:=DateStr;
            if MinDate1>DateStr1 Then MinDate:=DateStr; 
          end;
        {     //////////////
             If MaxDate1<DateStr1 Then MaxDate:=DateStr;
             if MinDate1>DateStr1 Then MinDate:=DateStr;  }      end;
          RecordCount_Edit_S.Text:=IntToStr(Count);
          If (MaxDate+MinDate)<>'' Then
            DateRange_Edit_S.Text:= MinDate+'  至  '+ MaxDate
          else
            DateRange_Edit_S.Text:='';
            if (mindate<>'') and (maxdate<>'') then
            begin
              if length(DateStr)<7 then
              begin
                  yyyy:=strtoint(copy(mindate,1,4));
                  mm:=strtoint(copy(mindate,5,2));
                  yyyy1:=strtoint(copy(maxdate,1,4));
                  mm1:=strtoint(copy(maxdate,5,2));
              end
              else
              begin
                 DecodeDate(STRTODATETIME(minDate),yyyy,mm,dd);
                 DecodeDate(STRTODATETIME(maxDate),yyyy1,mm1,dd1);
              end;
              startDate_edit_y.Text:=inttostr(yyyy);
              if mm<10 then
              startDate_edit_M.Text:='0'+inttostr(mm)
              else
              startDate_edit_M.Text:=inttostr(mm);
              if dd<10 then
              Start_Edit_D.Text:='0'+inttostr(dd)
              else
              Start_Edit_D.Text:=inttostr(dd);          EndDate_edit_y.Text:=inttostr(yyyy1);
              if mm1<10 then
              EndDate_edit_M.Text:='0'+inttostr(mm1)
              else
              EndDate_edit_M.Text:=inttostr(mm1);
              if dd1<10 then
              End_edit_d.Text:='0'+inttostr(dd1)
              else
              End_edit_d.Text:=inttostr(dd1);
             end;
    end;
      

  5.   

    上面的是把EXCEL导入到ORACLE的程序
      

  6.   

    也可以用ADO连接两个数据库,同时对两个数据库进行操作。这样也挺简单。