I have created one file
c;/temp/test.txt
000 23102007
001 21102007 [23102007 GB11223344
001 20102007 22102007 GB11223345
001 19102007 22102007 GB11223346
999 3
The highlighted text are started date and end date
Suppose I wanted to write a select statement by reading the data from the test.txt .. In my where clause I have to give input parameter as start date and end date .
cud u please tell me how to to it .
Thnaks
16 4725
I have created one file
c;/temp/test.txt
000 23102007
001 21102007 [23102007 GB11223344
001 20102007 22102007 GB11223345
001 19102007 22102007 GB11223346
999 3
The highlighted text are started date and end date
Suppose I wanted to write a select statement by reading the data from the test.txt .. In my where clause I have to give input parameter as start date and end date .
cud u please tell me how to to it .
Thnaks
Kindly POST what you have tried to achieve this?
If you want to use input parameters for fetching the data, then
1. transfer the data from flat file in to oracle database table
2. from the table, make use of select statement to fetch the data by passing input parameters
I have created following block -
-
SQL> declare
-
2 filename varchar2(1000);
-
3 input_file utl_file.file_type;
-
4 input_buffer integer;
-
5 vNewLine varchar2(1000);
-
6 begin
-
7 input_file := utl_file.fopen ('/tmp','ADDER_GENEVA_REVENUE_REQUEST_23102007121005.dat', 'R'
-
);
-
8 LOOP
-
9 BEGIN
-
10 utl_file.get_line(input_file,vNewLine);
-
11 --insert into test_12 values(vNewLine);
-
12 dbms_output.put_line(vNewLine);
-
13 EXCEPTION
-
14 WHEN OTHERS THEN
-
15 EXIT;
-
16 END;
-
17 END LOOP;
-
18 utl_file.fclose(input_file);
-
19 end;
-
20 /
-
The output as
000 23102007
001 21102007 23102007 GB11223344
001 20102007 22102007 GB11223345
001 19102007 22102007 GB11223346
999 3
PL/SQL procedure successfully completed.
Now I wanted to store the highligted date in the variable ...how shoud i do the Cud u plz tell me .
Thanks
I have created following block
SQL> declare
2 filename varchar2(1000);
3 input_file utl_file.file_type;
4 input_buffer integer;
5 vNewLine varchar2(1000);
6 begin
7 input_file := utl_file.fopen ('/tmp','ADDER_GENEVA_REVENUE_REQUEST_23102007121005. dat', 'R'
);
8 LOOP
9 BEGIN
10 utl_file.get_line(input_file,vNewLine);
11 --insert into test_12 values(vNewLine);
12 dbms_output.put_line(vNewLine);
13 EXCEPTION
14 WHEN OTHERS THEN
15 EXIT;
16 END;
17 END LOOP;
18 utl_file.fclose(input_file);
19 end;
20 /
The output as
000 23102007
001 21102007 23102007 GB11223344
001 20102007 22102007 GB11223345
001 19102007 22102007 GB11223346
999 3
PL/SQL procedure successfully completed.
Now I wanted to store the highligted date in the variable ...how shoud i do the Cud u plz tell me .
Thanks
Do you have the data stored in oracle table that you have ina flat file?
No .I wanted to store the highligted text (date ) into the(two ) variables and Insert it in the table .
No .I wanted to store the highligted text (date ) into the(two ) variables and Insert it in the table .
Try something like this: -
declare
-
start_date VARCHAR2(20);
-
end_date VARCHAR2(20);
-
buffer VARCHAR2(200);
-
BEGIN
-
--<your utl file code goes here>;
-
--buffer:= getline() function to read a line from the file
-
start_date := SUBSTR(buffer,5,8);
-
IF(length(buffer) > 13) THEN
-
end_date:= SUBSTR(buffer,14,8);
-
INSERT INTO table_name VALUES(start_date,end_date);
-
COMMIT;
-
END;
-
Thanks for ur solution ..but still facing some probm -
DECLARE
-
start_date VARCHAR2(20);
-
end_date VARCHAR2(20);
-
buffer VARCHAR2(2000);
-
filename VARCHAR2(1000);
-
input_file utl_file.file_type;
-
input_buffer INTEGER;
-
vNewLine VARCHAR2(1000);
-
BEGIN
-
loop
-
begin
-
input_file := utl_file.fopen ('/tmp','ADDER_GENEVA_REVENUE_REQUEST_23102007121005. dat', 'R');
-
buffer:=utl_file.get_line(input_file,vNewLine);
-
dbms_output.put_line(buffer);
-
start_date := SUBSTR(buffer,5,8);
-
IF(LENGTH(buffer) > 13) THEN
-
end_date:= SUBSTR(buffer,14,8);
-
end if;
-
INSERT INTO am_test VALUES(start_date,end_date);
-
COMMIT;
-
EXCEPTION
-
WHEN OTHERS THEN
-
EXIT;
-
END;
-
END LOOP;
-
utl_file.fclose(input_file);
-
end;
-
But it gives me one error
ORA-06550: line 13, column 17:
PLS-00222: no function with name 'GET_LINE' exists in this scope
Thanks for ur solution ..but still facing some probm -
DECLARE
-
start_date VARCHAR2(20);
-
end_date VARCHAR2(20);
-
buffer VARCHAR2(2000);
-
filename VARCHAR2(1000);
-
input_file utl_file.file_type;
-
input_buffer INTEGER;
-
vNewLine VARCHAR2(1000);
-
BEGIN
-
loop
-
begin
-
input_file := utl_file.fopen ('/tmp','ADDER_GENEVA_REVENUE_REQUEST_23102007121005. dat', 'R');
-
buffer:=utl_file.get_line(input_file,vNewLine);
-
dbms_output.put_line(buffer);
-
start_date := SUBSTR(buffer,5,8);
-
IF(LENGTH(buffer) > 13) THEN
-
end_date:= SUBSTR(buffer,14,8);
-
end if;
-
INSERT INTO am_test VALUES(start_date,end_date);
-
COMMIT;
-
EXCEPTION
-
WHEN OTHERS THEN
-
EXIT;
-
END;
-
END LOOP;
-
utl_file.fclose(input_file);
-
end;
-
But it gives me one error
ORA-06550: line 13, column 17:
PLS-00222: no function with name 'GET_LINE' exists in this scope
Please use the below code: -
DECLARE
-
start_date VARCHAR2(20);
-
end_date VARCHAR2(20);
-
filename VARCHAR2(1000);
-
input_file utl_file.file_type;
-
input_buffer INTEGER;
-
vNewLine VARCHAR2(1000);
-
BEGIN
-
input_file := utl_file.fopen ('/tmp','ADDER_GENEVA_REVENUE_REQUEST_23102007121005. dat', 'R');
-
utl_file.get_line(input_file,vNewLine);
-
LOOP
-
EXIT WHEN length(vNewLine) <= 0);
-
dbms_output.put_line(vNewLine);
-
start_date := SUBSTR(vNewLine,5,8);
-
IF(LENGTH(vNewLine) > 13) THEN
-
end_date:= SUBSTR(vNewLine,14,8);
-
end if;
-
INSERT INTO am_test VALUES(start_date,end_date);
-
COMMIT;
-
vNewLine:= NULL;
-
END LOOP;
-
EXCEPTION
-
WHEN OTHERS THEN
-
utl_file.fclose(input_file);
-
END;
-
Thanks for ur solution .. It run successfully
SQL> select * from am_test;
START_DATE END_DATE
-------------------- -------------------- 23102007
21102007 23102007
20102007 22102007
19102007 22102007 3 22102007
But I dont want the highlighted data ...
Input file is
000 23102007
001 21102007 23102007 GB11223344
001 20102007 22102007 GB11223345
001 19102007 22102007 GB11223346
999 3
I wanted to insert only highlighted values ...
Ur last comment on this issue plz.
Thank u very much
Use the below code: -
DECLARE
-
start_date VARCHAR2(20);
-
end_date VARCHAR2(20);
-
filename VARCHAR2(1000);
-
input_file utl_file.file_type;
-
input_buffer INTEGER;
-
vNewLine VARCHAR2(1000);
-
BEGIN
-
input_file := utl_file.fopen ('/tmp','ADDER_GENEVA_REVENUE_REQUEST_23102007121005. dat', 'R');
-
utl_file.get_line(input_file,vNewLine);
-
LOOP
-
EXIT WHEN length(vNewLine) <= 0);
-
dbms_output.put_line(vNewLine);
-
IF(LENGTH(vNewLine) > 13) THEN
-
start_date := SUBSTR(vNewLine,5,8);
-
end_date:= SUBSTR(vNewLine,14,8);
-
INSERT INTO am_test VALUES(start_date,end_date);
-
COMMIT;
-
end if;
-
vNewLine:= NULL;
-
start_date:= NULL;
-
end_date:= NULL;
-
END LOOP;
-
EXCEPTION
-
WHEN OTHERS THEN
-
utl_file.fclose(input_file);
-
END;
-
Use the below code: -
DECLARE
-
start_date VARCHAR2(20);
-
end_date VARCHAR2(20);
-
filename VARCHAR2(1000);
-
input_file utl_file.file_type;
-
input_buffer INTEGER;
-
vNewLine VARCHAR2(1000);
-
BEGIN
-
input_file := utl_file.fopen ('/tmp','ADDER_GENEVA_REVENUE_REQUEST_23102007121005. dat', 'R');
-
utl_file.get_line(input_file,vNewLine);
-
LOOP
-
EXIT WHEN length(vNewLine) <= 0);
-
dbms_output.put_line(vNewLine);
-
IF(LENGTH(vNewLine) > 13) THEN
-
start_date := SUBSTR(vNewLine,5,8);
-
end_date:= SUBSTR(vNewLine,14,8);
-
INSERT INTO am_test VALUES(start_date,end_date);
-
COMMIT;
-
end if;
-
vNewLine:= NULL;
-
start_date:= NULL;
-
end_date:= NULL;
-
END LOOP;
-
EXCEPTION
-
WHEN OTHERS THEN
-
utl_file.fclose(input_file);
-
END;
-
if i have my txt file as shown below ... the space is replaced by pipe'|' . Now I wanted to instert the pipe seperated values using above code ..
Could u please tell me how to do that ...
000|23102007
001| 21102007|23102007|GB11223344
001| 20102007|22102007|GB11223345
001| 19102007|22102007|GB11223346
999|3
Thank you very much..
if i have my txt file as shown below ... the space is replaced by pipe'|' . Now I wanted to instert the pipe seperated values using above code ..
Could u please tell me how to do that ...
000|23102007
001|21102007|23102007|GB11223344
001|20102007|22102007|GB11223345
001|19102007|22102007|GB11223346
999|3
Thank you very much..
You can try using the same code that I have provided you in the prevoius post. Its just that the space is replaced by a pipe and my above posted code will work for this file as well. If it does not then POST back here and we will help you out!!
Thanks u for ur valuable time .. I will try from my side and get back to u ..thanks
yes its working ... thanks for your help
yes its working ... thanks for your help
You are welcome :)
MODERATOR
if i have my txt file as shown below ...
000|23102007
001|R|21102007|23102007|GD112112111|B|LIss
001|R|20102007|22102007|GD112|B|WOss
001|R|19102007|22102007|GD113334444223346||WOss
001|R|19102007|22102007|GD111||WOss
001|R|19102007|22102007|GD113344||WOss
999|5
Now i wanted to read and insert account number using above code ... The account number is shown as bold (GD133331223344,GD112 etc)
Could u please advice me how to do it.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Souhail |
last post by:
Hi all,
I have a problem to put lines with about 3000 characters in my output
file using UTL_FILE.put package.
I'm using Oracle 7 !! So I can not specify the line size in
UTL_FILE.FOPEN...
|
by: Mahesh Hardikar |
last post by:
Hi ,
Oracle EE 8.1.7.0.0 on MS WIndows Advanced Server 2000 SP3
We have a proc which is using utl_file .
procedure test_dump_csv
as
l_rows number;
begin
|
by: Candy Robinson |
last post by:
I have created a directory for the path name I use for a UTL_FILE.OPEN
call, but when I run my call I get error ORA-29280 invalid directory
path. What am I failing to do? Thanks for your help,
...
|
by: Peter Weidner |
last post by:
Hello friends
I have a problem with UTL_File under Oracle 9.2i there - operating
system Windows 2000 Professional.
Following: I have a procedure in a Package, that reads from an
Utl_File and...
|
by: Shilpesh |
last post by:
I have an issue in usage of utl_file package. I have setup
utl_file_dir parameters correctly on the database side.
Basically my goal is to convert csv files into table-structure. I do
not know...
| |
by: Zima |
last post by:
Hi
I'm using Oracle 9i
My question is how can I use utl_file with network path utl_file_dir
like '\\mycomputer\FolderA'
I know that in this way this is illegal, and I know that on mycomputer...
|
by: Prasanna |
last post by:
Hi All
Nice to be in this Forum.
I have questions to ask on UTL_FILE :roll:
Let me explain the concept
1.When the net is down the user will take the records into on
floppy(CLIENT
2.When the net...
|
by: djramesh04 |
last post by:
ORA-29280: invalid directory path
ORA-06512: at "SYS.UTL_FILE", line 33
ORA-06512: at "SYS.UTL_FILE", line 436
ORA-06512: at "CPLNMGR.PARSE_STRING", line 13
ORA-06512: at line 1
CREATE OR...
|
by: orajit |
last post by:
I have created one file
c;/temp/test.txt
000|23102007
001|21102007|23102007|GB11223344
001|20102007|22102007|GB11223345
001|19102007|22102007|GB11223346
999|3
The highlighted text are...
|
by: abulafia |
last post by:
Originally posted by Julia Sats
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |