怎样用sqlldr 把分块数据存入不同的表中

haihai323 2003-05-27 02:58:43
数据文件格式如下:
-1
1.57869E-16 7.34452E-07 6.38861E-07 6.30110E-07 8.41587E-07 8.25447E-07
1.06335E-06 1.41626E-06 1.94109E-06 3.38321E-06 6.78082E-06 1.75458E-05
1.60159E-04 1.73167E-04 2.15117E-05
-1
-1
1.90394E-07 2.06267E-07 1.95467E-07 1.77876E-07 1.58910E-07 1.46539E-07
1.25418E-07 7.87737E-08 1.55826E-07 1.39546E-07 1.47856E-07 1.37375E-07
9.30915E-08 1.53957E-07
-1
说明:上面的数据分为两块,每两个 '-1' 之间的数据是一块,现在我想把第一块数据导入table1, 第二块数据导入 table2
请问控制文件怎么写? 请各位大侠帮忙
...全文
41 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
junerr 2003-06-01
  • 打赏
  • 举报
回复
说明:
本人略懂Delphi ,常在Delphi版快里混, 所以一时糊涂 :)
上面给出的代码是Delphi中的
你用Delphi 吗?是的话可以把代码放在Delphi中试试
要是不用Delphi...我也不知道在sql*plus中用什么命令,或者在其他编程工具中的具体做法
但思路可以是一样的
haihai323 2003-05-31
  • 打赏
  • 举报
回复
declare
f textfile;
temp string;
x double;

begin
assignfile(f,'e:\Aeronautics\test\noise5.txt'); //filename是你的文件
reset(f);
readln(temp); //temp='-1'
readln(temp); //如果第一个快只有一行,整行都存在了temp中
repeat
x:=strtofloat(copy(temp,1,pos(' ',temp)-1)); //取一个数
InsertTable1(x);
delete(temp,1,pos(' ',temp));
until pos(' ',temp)=0; //pos(' ',temp)=0 表示数已取完
readln(temp); //temp='-1'
readln(temp); //temp='-1'
readln(temp); //temp=第二个数据块
repeat
x:=strtofloat(copy(temp,1,pos(' ',temp)-1)); //取一个数
InsertTable2(x);
delete(temp,1,pos(' ',temp));
until pos(' ',temp)=0; //pos(' ',temp)=0 表示数已取完
closefile(f);
end;

procudure InsertTable1(x: double);
begin
form1.query1.sql.text:='insert into table1 (result1) values (:result1)';
form1.query1.parambyname('result1').asfloat:=x;
form1.query1.execsql;
end;

procudure InsertTable2(x: double);
begin
form1.query2.sql.text:='insert into table2 (result1) values (:result2)';
form1.query2.parambyname('result2').asfloat:=x;
form1.query2.execsql;
end;

除了前面的申明部分有点改动,文件名写全之外,其余都没变化,这些程序在sql*plus里边运行
多谢相助
junerr 2003-05-30
  • 打赏
  • 举报
回复
请把你整个单元的代码帖出来看看
haihai323 2003-05-29
  • 打赏
  • 举报
回复
多谢junerr
这段程序在 SQL*Plus 里边运行时出现这样的错误:
SP2-0553: 非法的变量名\f:\。
SP2-0734: 未知的命令开头 "temp: stri..." - 忽略了剩余的行。
SP2-0042: 未知命令"x: double" -- 其余行忽略。
SP2-0552: 未说明结合变量"DOUBLE"

我把 var 改为 declare 后,还是有错误 :SP2-0552: 未说明结合变量"DOUBLE"
我是新手,还望指教,谢谢
junerr 2003-05-28
  • 打赏
  • 举报
回复
var f: textfile;
temp: string;
x: double;
begin
assignfile(f,filename); //filename是你的文件
reset(f);
readln(temp); //temp='-1'
readln(temp); //如果第一个快只有一行,整行都存在了temp中
repeat
x:=strtofloat(copy(temp,1,pos(' ',temp)-1)); //取一个数
InsertTable1(x);
delete(temp,1,pos(' ',temp));
until pos(' ',temp)=0; //pos(' ',temp)=0 表示数已取完
readln(temp); //temp='-1'
readln(temp); //temp='-1'
readln(temp); //temp=第二个数据块
repeat
x:=strtofloat(copy(temp,1,pos(' ',temp)-1)); //取一个数
InsertTable2(x);
delete(temp,1,pos(' ',temp));
until pos(' ',temp)=0; //pos(' ',temp)=0 表示数已取完
closefile(f);
end;

procudure InsertTable1(x: double);
begin
form1.query1.sql.text:='insert into table1 (result1) values (:result1)';
form1.query1.parambyname('result1').asfloat:=x;
form1.query1.execsql;
end;

procudure InsertTable2(x: double);
begin
form1.query2.sql.text:='insert into table2 (result1) values (:result2)';
form1.query2.parambyname('result2').asfloat:=x;
form1.query2.execsql;
end;
haihai323 2003-05-28
  • 打赏
  • 举报
回复
谢谢上面的兄弟

能再详细点吗? 怎么定位阿?
比如两个表格都只有一个字段,分别为 result1 ,result2

haihai323 2003-05-28
  • 打赏
  • 举报
回复
Re 一个,高手请指教
junerr 2003-05-28
  • 打赏
  • 举报
回复
>定位在第一个“块”
>每次读一个数,导入table1,直到块尾
>定位在第二个块
>每次读一个数,导入table2,直到块尾

——最简单的方法往往是最好的方法
haihai323 2003-05-27
  • 打赏
  • 举报
回复
很难吗,分数不够还可以加
大家帮帮忙

17,137

社区成员

发帖
与我相关
我的任务
社区描述
Oracle开发相关技术讨论
社区管理员
  • 开发
  • Lucifer三思而后行
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧