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','11111111 1111','11',1111 1,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','111111111 1111','','','', '','','19-Jan-2005','','','', ''
( '12-Dec-2004','
','2','22222222 2222','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','222222222 2222','','','', '','','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(Question s)
_______________ _______________ _______________ _________
CREATE OR REPLACE PROCEDURE BackupRestore (file_name IN VARCHAR2) I
vSFile utl_file.file_t ype
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_li ne(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.invali d_mode THE
RAISE_APPLICATI ON_ERROR (-20051, 'Invalid Mode Parameter')
WHEN utl_file.invali d_path THE
RAISE_APPLICATI ON_ERROR (-20052, 'Invalid File Location')
WHEN utl_file.invali d_filehandle THE
RAISE_APPLICATI ON_ERROR (-20053, 'Invalid Filehandle')
WHEN utl_file.invali d_operation THE
RAISE_APPLICATI ON_ERROR (-20054, 'Invalid Operation')
WHEN utl_file.read_e rror THE
RAISE_APPLICATI ON_ERROR (-20055, 'Read Error')
WHEN utl_file.intern al_error THE
RAISE_APPLICATI ON_ERROR (-20057, 'Internal Error')
WHEN utl_file.file_o pen THE
RAISE_APPLICATI ON_ERROR (-20059, 'File Already Opened')
WHEN utl_file.invali d_maxlinesize THE
RAISE_APPLICATI ON_ERROR(-20060,'Line Size Exceeds 32K')
WHEN utl_file.invali d_filename THE
RAISE_APPLICATI ON_ERROR (-20061, 'Invalid File Name')
WHEN utl_file.access _denied THE
RAISE_APPLICATI ON_ERROR (-20062, 'File Access Denied By')
WHEN others THE
RAISE_APPLICATI ON_ERROR (-20099, 'Unknown UTL_FILE Error')
END read_demo
_______________ _______________ _______________ _______
Sorry for taking your valuable time.Thanks for spending your time
Waiting for your reply
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','11111111 1111','11',1111 1,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','111111111 1111','','','', '','','19-Jan-2005','','','', ''
( '12-Dec-2004','
','2','22222222 2222','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','222222222 2222','','','', '','','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(Question s)
_______________ _______________ _______________ _________
CREATE OR REPLACE PROCEDURE BackupRestore (file_name IN VARCHAR2) I
vSFile utl_file.file_t ype
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_li ne(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.invali d_mode THE
RAISE_APPLICATI ON_ERROR (-20051, 'Invalid Mode Parameter')
WHEN utl_file.invali d_path THE
RAISE_APPLICATI ON_ERROR (-20052, 'Invalid File Location')
WHEN utl_file.invali d_filehandle THE
RAISE_APPLICATI ON_ERROR (-20053, 'Invalid Filehandle')
WHEN utl_file.invali d_operation THE
RAISE_APPLICATI ON_ERROR (-20054, 'Invalid Operation')
WHEN utl_file.read_e rror THE
RAISE_APPLICATI ON_ERROR (-20055, 'Read Error')
WHEN utl_file.intern al_error THE
RAISE_APPLICATI ON_ERROR (-20057, 'Internal Error')
WHEN utl_file.file_o pen THE
RAISE_APPLICATI ON_ERROR (-20059, 'File Already Opened')
WHEN utl_file.invali d_maxlinesize THE
RAISE_APPLICATI ON_ERROR(-20060,'Line Size Exceeds 32K')
WHEN utl_file.invali d_filename THE
RAISE_APPLICATI ON_ERROR (-20061, 'Invalid File Name')
WHEN utl_file.access _denied THE
RAISE_APPLICATI ON_ERROR (-20062, 'File Access Denied By')
WHEN others THE
RAISE_APPLICATI ON_ERROR (-20099, 'Unknown UTL_FILE Error')
END read_demo
_______________ _______________ _______________ _______
Sorry for taking your valuable time.Thanks for spending your time
Waiting for your reply
Comment