Topic: Backup & Recovery >> How to import data from text file (.lst format)
|
Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property.
You may review the entire Oracle Certification Program Candidate Agreement online Here.
|
|
|
|
| Title: How to import data from text file (.lst format) |
| Fahad |
Posted: Aug 10, 2006 04:00:34 AM |
Total Post: 3
Joined: Jan, 2006
|
I want to import data from .lst file to my oracle database, can any one tell me the procedure to accomplish this task. i tried UTL method but its not working.
here is the sample data that i want to import
01AUG2006|AKDITF|27500|||
01AUG2006|ABCF|200500|||
01AUG2006|AMMF|17000|||
01AUG2006|ATFF|63000|||
01AUG2006|BSBF|18000|||
01AUG2006|CPMFI|500|||
01AUG2006|GASF|349000|||
01AUG2006|PGF|4649000||| |
|
|
snehalatha |
| Posted: Aug 10, 2006 06:24:25 AM | |
|
Total Post: 169
Joined: Apr, 2006
|
Use the SQLLOADER.(In control file specify the format).
Hope this helps
|
|
|
|
|
Bhupendra |
| Posted: Aug 14, 2006 02:18:40 AM | |
|
Total Post: 8
Joined: Jul, 2006
|
Dear,
You can try SQLLOADER , even UTL_FILE package should work and easier then LOADER , what error you'r getting ?
sample code :
-------------
Declare
v_file UTL_FILE.File_Type;
mline varchar2(100);
mver varchar2(50);
mstp number := 0;
mcnt number := 0;
fld1 varchar2(15);
fld2 varchar2(15);
fld3 varchar2(15);
fld4 varchar2(15);
fld5 varchar2(15);
Begin
v_file := utl_file.fopen('c:\DATA\','xyz.txt','r');
Loop
Begin
utl_file.get_line(v_file, mLine);
mcnt := 1;
mstp := 1;
Loop
exit when mcnt > 5;
select substr(mline,mstp,instr(mline,'|',mstp,1)-mstp) into mver from dual;
mstp := instr(mline,'|',1,mcnt)+1;
case mcnt
when 1 then
fld1 := mver;
when 2 then
fld2 := mver;
when 3 then
fld3 := mver;
when 4 then
fld4 := mver;
when 5 then
fld5 := mver;
End Case;
mcnt := mcnt + 1;
End Loop;
Insert into ABC values (fld1,fld2,fld3,fld4,fld5);
EXCEPTION
WHEN OTHERS THEN
EXIT;
End;
End Loop;
utl_file.fclose(v_file);
commit;
End;
Best OF Luck
Bhupendra Patel
|
|
|
|
|
| Time Zone: EDT |
Send this thread to your friend |
|
|
|
|
Forum Rules & Description
Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user
|
| |
Get FREE Magazines
|
Top 10 Forum User
|
| Murtuja Khokhar | 857 |
| Mohammed Taj | 746 |
| positive fanatic | 483 |
| Jayanta Sur | 479 |
| Vigyan Kaushik | 386 |
| Gopu Gopi | 327 |
| Gitesh Trivedi | 322 |
| Vinoth Kumar | 264 |
| neeraj sharma | 258 |
| Ramesh Jois | 246 |
|
|