473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

UTL_FILE(HELP)

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 is up he will update the database(SERVER) with all th
trasaction including the records which he taken into the floppy

He creates one text file in the floppy. The records in that text fil
will be as follows

( '12-Dec-2004','
','1','111111111111','11',11111,11111,'',0,'Z','N' ,'M',
','N',11111,0,' ','12-Dec-2004',' ',0,' ',' ',' ',' ',0,'
','12-Dec-2004','
',0,'1','315','tpsl','06:45:26',1,'N','C','Y','D', '1111','F','192.100.10.1','N','1111111111111','',' ','','','','19-Jan-2005','','','',''
( '12-Dec-2004','
','2','222222222222','22',1254,1254,'',0,'Z','N',' M',' ','N',1254,0,
','12-Dec-2004',' ',0,' ',' ',' ',' ',0,'
','12-Dec-2004','
',0,'2','315','TPSL','07:07:11',1,'N','C','Y','D', '2222','F','192.100.10.1','N','2222222222222','',' ','','','','19-Jan-2005','','','',''

Question
********
1. Is it possible to pass floppy drive A: as parameter to UTL_FILE
2. If yes then do I need to create directory for this
3. If no then can I copy the file in floppy to other location fro
procedure
4. If yes then how can i do that
5. When I get the line from UTL_FILE handler Iam straight awa
inserting the line. Like for exampl
INSERT INTO CDYYMMDD1 VALUES(vNewLine)
Is is possible
6. How to go to the next line of UTL_FILE
7.How to open that file in a procedure

It will be very useful if you send in any sample code of same issue
Iam here with pasting you the procedure which I have implemented.Bu
it is not working due to the above mentioned Errors(Questions)
__________________________________________________ ____
CREATE OR REPLACE PROCEDURE BackupRestore (file_name IN VARCHAR2) I
vSFile utl_file.file_type
vNewLine VARCHAR2(200)
vTNO VARCHAR2(6)
vTDate DATE
vMach VARCHAR2(3)

BEGIN
vSFile := utl_file.fopen('A:', file_name,'r')
LOOP
BEGIN
utl_file.get_line(vSFile, vNewLine)
DBMS_OUTPUT.PUT_LINE(vNewLine)
vTDate = substr(vNewLine,1,13
vTNo := SUBSTR(vNewLine,21,1)
vMach := SUBSTR(vNewLine,77,3)
FOR I IN (SELECT TRNNO, CONS_NO,MACHINE FROM CDYYMMDD
WHERE TRNDATE = vTDate AND
(TRNNo = vTNo AND MACHINE = vMach)) LOO
IF I = 0 then
INSERT INTO CDYYMMDD1 VALUES(vNewLine)
END IF
END LOOP

EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
COMMIT
utl_file.fclose(vSFile);
EXCEPTIO
WHEN utl_file.invalid_mode THE
RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter')
WHEN utl_file.invalid_path THE
RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location')
WHEN utl_file.invalid_filehandle THE
RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle')
WHEN utl_file.invalid_operation THE
RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation')
WHEN utl_file.read_error THE
RAISE_APPLICATION_ERROR (-20055, 'Read Error')
WHEN utl_file.internal_error THE
RAISE_APPLICATION_ERROR (-20057, 'Internal Error')
WHEN utl_file.file_open THE
RAISE_APPLICATION_ERROR (-20059, 'File Already Opened')
WHEN utl_file.invalid_maxlinesize THE
RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K')
WHEN utl_file.invalid_filename THE
RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name')
WHEN utl_file.access_denied THE
RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By')
WHEN others THE
RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error')
END read_demo

__________________________________________________ __
Sorry for taking your valuable time.Thanks for spending your time
Waiting for your reply

Jul 19 '05 #1
2 10616

"Prasanna" <pr*********@rediffmail-dot-com.no-spam.invalid> wrote in message
news:fN********************@giganews.com...
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 one
floppy(CLIENT)
2.When the net is up he will update the database(SERVER) with all the
trasaction including the records which he taken into the floppy.

He creates one text file in the floppy. The records in that text file
will be as follows.

( '12-Dec-2004','D
','1','111111111111','11',11111,11111,'',0,'Z','N' ,'M','
','N',11111,0,' ','12-Dec-2004',' ',0,' ',' ',' ',' ',0,'
','12-Dec-2004','
',0,'1','315','tpsl','06:45:26',1,'N','C','Y','D', '1111','F','192.100.10.1',
'N','1111111111111','','','','','','19-Jan-2005','','','','') ( '12-Dec-2004','D
','2','222222222222','22',1254,1254,'',0,'Z','N',' M',' ','N',1254,0,'
','12-Dec-2004',' ',0,' ',' ',' ',' ',0,'
','12-Dec-2004','
',0,'2','315','TPSL','07:07:11',1,'N','C','Y','D', '2222','F','192.100.10.1',
'N','2222222222222','','','','','','19-Jan-2005','','','','')
Questions
*********
1. Is it possible to pass floppy drive A: as parameter to UTL_FILE?
2. If yes then do I need to create directory for this?
3. If no then can I copy the file in floppy to other location from
procedure?
4. If yes then how can i do that?
5. When I get the line from UTL_FILE handler Iam straight away
inserting the line. Like for example
INSERT INTO CDYYMMDD1 VALUES(vNewLine);
Is is possible?
6. How to go to the next line of UTL_FILE?
7.How to open that file in a procedure?

It will be very useful if you send in any sample code of same issue.
Iam here with pasting you the procedure which I have implemented.But
it is not working due to the above mentioned Errors(Questions).
__________________________________________________ _____
CREATE OR REPLACE PROCEDURE BackupRestore (file_name IN VARCHAR2) IS
vSFile utl_file.file_type;
vNewLine VARCHAR2(200);
vTNO VARCHAR2(6);
vTDate DATE;
vMach VARCHAR2(3);

BEGIN
vSFile := utl_file.fopen('A:', file_name,'r');
LOOP
BEGIN
utl_file.get_line(vSFile, vNewLine);
DBMS_OUTPUT.PUT_LINE(vNewLine);
vTDate = substr(vNewLine,1,13)
vTNo := SUBSTR(vNewLine,21,1);
vMach := SUBSTR(vNewLine,77,3);
FOR I IN (SELECT TRNNO, CONS_NO,MACHINE FROM CDYYMMDD1
WHERE TRNDATE = vTDate AND
(TRNNo = vTNo AND MACHINE = vMach)) LOOP
IF I = 0 then
INSERT INTO CDYYMMDD1 VALUES(vNewLine);
END IF;
END LOOP;

EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
COMMIT;
utl_file.fclose(vSFile);
EXCEPTION
WHEN utl_file.invalid_mode THEN
RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
WHEN utl_file.invalid_path THEN
RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
WHEN utl_file.invalid_filehandle THEN
RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle');
WHEN utl_file.invalid_operation THEN
RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
WHEN utl_file.read_error THEN
RAISE_APPLICATION_ERROR (-20055, 'Read Error');
WHEN utl_file.internal_error THEN
RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
WHEN utl_file.file_open THEN
RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
WHEN utl_file.invalid_maxlinesize THEN
RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
WHEN utl_file.invalid_filename THEN
RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
WHEN utl_file.access_denied THEN
RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
WHEN others THEN
RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
END read_demo;
/
__________________________________________________ ___
Sorry for taking your valuable time.Thanks for spending your time.
Waiting for your reply.


Utl_file runs on the Server not the client so the server can't see the A:
drive on the client. Why not have your client issue the commands to the
server as SQL inserts.
Jim
Jul 19 '05 #2

"Prasanna" <pr*********@rediffmail-dot-com.no-spam.invalid> wrote in message
news:fN********************@giganews.com...
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 one
floppy(CLIENT)
2.When the net is up he will update the database(SERVER) with all the
trasaction including the records which he taken into the floppy.

He creates one text file in the floppy. The records in that text file
will be as follows.

( '12-Dec-2004','D
','1','111111111111','11',11111,11111,'',0,'Z','N' ,'M','
','N',11111,0,' ','12-Dec-2004',' ',0,' ',' ',' ',' ',0,'
','12-Dec-2004','
',0,'1','315','tpsl','06:45:26',1,'N','C','Y','D', '1111','F','192.100.10.1','N','1111111111111','',' ','','','','19-Jan-2005','','','','')
( '12-Dec-2004','D
','2','222222222222','22',1254,1254,'',0,'Z','N',' M',' ','N',1254,0,'
','12-Dec-2004',' ',0,' ',' ',' ',' ',0,'
','12-Dec-2004','
',0,'2','315','TPSL','07:07:11',1,'N','C','Y','D', '2222','F','192.100.10.1','N','2222222222222','',' ','','','','19-Jan-2005','','','','')

Questions
*********
1. Is it possible to pass floppy drive A: as parameter to UTL_FILE?
2. If yes then do I need to create directory for this?
3. If no then can I copy the file in floppy to other location from
procedure?
4. If yes then how can i do that?
5. When I get the line from UTL_FILE handler Iam straight away
inserting the line. Like for example
INSERT INTO CDYYMMDD1 VALUES(vNewLine);
Is is possible?
6. How to go to the next line of UTL_FILE?
7.How to open that file in a procedure?

It will be very useful if you send in any sample code of same issue.
Iam here with pasting you the procedure which I have implemented.But
it is not working due to the above mentioned Errors(Questions).
__________________________________________________ _____
CREATE OR REPLACE PROCEDURE BackupRestore (file_name IN VARCHAR2) IS
vSFile utl_file.file_type;
vNewLine VARCHAR2(200);
vTNO VARCHAR2(6);
vTDate DATE;
vMach VARCHAR2(3);

BEGIN
vSFile := utl_file.fopen('A:', file_name,'r');
LOOP
BEGIN
utl_file.get_line(vSFile, vNewLine);
DBMS_OUTPUT.PUT_LINE(vNewLine);
vTDate = substr(vNewLine,1,13)
vTNo := SUBSTR(vNewLine,21,1);
vMach := SUBSTR(vNewLine,77,3);
FOR I IN (SELECT TRNNO, CONS_NO,MACHINE FROM CDYYMMDD1
WHERE TRNDATE = vTDate AND
(TRNNo = vTNo AND MACHINE = vMach)) LOOP
IF I = 0 then
INSERT INTO CDYYMMDD1 VALUES(vNewLine);
END IF;
END LOOP;

EXCEPTION
WHEN NO_DATA_FOUND THEN
EXIT;
END;
END LOOP;
COMMIT;
utl_file.fclose(vSFile);
EXCEPTION
WHEN utl_file.invalid_mode THEN
RAISE_APPLICATION_ERROR (-20051, 'Invalid Mode Parameter');
WHEN utl_file.invalid_path THEN
RAISE_APPLICATION_ERROR (-20052, 'Invalid File Location');
WHEN utl_file.invalid_filehandle THEN
RAISE_APPLICATION_ERROR (-20053, 'Invalid Filehandle');
WHEN utl_file.invalid_operation THEN
RAISE_APPLICATION_ERROR (-20054, 'Invalid Operation');
WHEN utl_file.read_error THEN
RAISE_APPLICATION_ERROR (-20055, 'Read Error');
WHEN utl_file.internal_error THEN
RAISE_APPLICATION_ERROR (-20057, 'Internal Error');
WHEN utl_file.file_open THEN
RAISE_APPLICATION_ERROR (-20059, 'File Already Opened');
WHEN utl_file.invalid_maxlinesize THEN
RAISE_APPLICATION_ERROR(-20060,'Line Size Exceeds 32K');
WHEN utl_file.invalid_filename THEN
RAISE_APPLICATION_ERROR (-20061, 'Invalid File Name');
WHEN utl_file.access_denied THEN
RAISE_APPLICATION_ERROR (-20062, 'File Access Denied By');
WHEN others THEN
RAISE_APPLICATION_ERROR (-20099, 'Unknown UTL_FILE Error');
END read_demo;
/
__________________________________________________ ___
Sorry for taking your valuable time.Thanks for spending your time.
Waiting for your reply.


what is you client interface/tool?

what version of oracle?

as jim kennedy noted, utl_file is server side...

if you have a situation where client connectivity is a problem, is the issue
only related to writes (inserts)? or do you also have to make provisions for
reads?

in the simplest scenario, where you're just pushing data from the client and
need to buffer it locally if the network connection is down, why not just
save the SQL INSERT statements to a file (presumably on the hard disk, not
on the floppy drive) and then reissue them when the connection is up?

++ mcs
Jul 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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
2
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, ...
0
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...
1
by: Scott J. Chlebove | last post by:
I am running a PL/SQL module in which I do the following.... BEGIN DBMS_OUTPUT.enable(1000000); -- Open file for writing. OutfileHandler1 := UTL_FILE.FOPEN(wc_file_path, wc_output_file1,...
1
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...
1
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...
0
by: ARUNB | last post by:
I have to write a procedure using spooling techniques where the procedure will take some data from a table and will write it in a file defined in the spool command. I'm giving the...
9
by: san1014 | last post by:
Hi I have created a procedure using UTL_FILE. Before executing the procedure i created a directory as connect system/system; grant execute on sys.utl_file to PUBLIC;
2
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...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.