知识点
1.自动产生id
2.定长数据处理
3.自定义函数使用.
unrecoverable
LOAD DATA
INFILE 'tmp.txt'
BADFILE 'tmp.bad'
TRUNCATE
INTO TABLE sss
(
ID sequence (max,1),
主叫号码 POSITION(01:22) "decode(:主叫号码,'00C','',:主叫号码)",
主叫号码长度 "decode(:主叫号码,'00C',0,length(:主叫号码))",
被叫号码 POSITION(23:42),
被叫号码长度 "length(:被叫号码)",
通话时间 POSITION(43:82) "FUNC_GETDATE(:通话时间)",
通话长度 POSITION(43:82) "FUNC_GETTHSJ(:通话长度)"
)
LOAD DATA
INFILE 'tmp.txt'
BADFILE 'tmp.bad'
TRUNCATE
INTO TABLE sss
(
ID sequence (max,1),
主叫号码 POSITION(01:22) "decode(:主叫号码,'00C','',:主叫号码)",
主叫号码长度 "decode(:主叫号码,'00C',0,length(:主叫号码))",
被叫号码 POSITION(23:42),
被叫号码长度 "length(:被叫号码)",
通话时间 POSITION(43:82) "FUNC_GETDATE(:通话时间)",
通话长度 POSITION(43:82) "FUNC_GETTHSJ(:通话长度)"
)
函数代码
CREATE OR REPLACE FUNCTION "FUNC_GETDATE" (
str in varchar2
)
return varchar2
as
begin
return '20' || substr(str,6,2) ||'-' || substr(str,8,2) ||'-' || substr(str,10,2) || ' ' || substr(str,12,2)|| ':' || substr(str,14,2) || ':' || substr(str,16,2);
end;
str in varchar2
)
return varchar2
as
begin
return '20' || substr(str,6,2) ||'-' || substr(str,8,2) ||'-' || substr(str,10,2) || ' ' || substr(str,12,2)|| ':' || substr(str,14,2) || ':' || substr(str,16,2);
end;
CREATE OR REPLACE FUNCTION "FUNC_GETTHSJ" (
str in varchar
)
return number
as
begin
return substr(str,18,6);
end;
str in varchar
)
return number
as
begin
return substr(str,18,6);
end;
sqlldr userid=aaa/bbb control=sssss.ctl log=a.log direct=yes