I have created one file
c;/temp/test.txt
000|23102007
001|21102007|231020 07|GB11223344
001|20102007|221020 07|GB11223345
001|19102007|221020 07|GB11223346
999|3
The highlighted text are started date and end date and account number .
Suppose I wanted to insert the date into am_test the from the test.txt by using following code
I dont wanted to use hardcoded values in my code means
IF(LENGTH(vNewL ine) > 13) THEN ... like this
I wanted to insert '|' seperated values in my table .
cud u please tell me how to to it .
Thnaks
[CODE=oracle]
DECLARE
start_date VARCHAR2(20);
end_date VARCHAR2(20);
filename VARCHAR2(1000);
input_file utl_file.file_t ype;
input_buffer INTEGER;
vNewLine VARCHAR2(1000);
BEGIN
input_file := utl_file.fopen ('/tmp','ADDER_GEN EVA_REVENUE_REQ UEST_2310200712 1005. dat', 'R');
utl_file.get_li ne(input_file,v NewLine);
LOOP
EXIT WHEN LENGTH(vNewLine ) <= 0);
dbms_output.put _line(vNewLine) ;
IF(LENGTH(vNewL ine) > 13) THEN
start_date := SUBSTR(vNewLine ,5,8);
end_date:= SUBSTR(vNewLine ,14,8);
INSERT INTO am_test VALUES(start_da te,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;
[/CODE]
c;/temp/test.txt
000|23102007
001|21102007|231020 07|GB11223344
001|20102007|221020 07|GB11223345
001|19102007|221020 07|GB11223346
999|3
The highlighted text are started date and end date and account number .
Suppose I wanted to insert the date into am_test the from the test.txt by using following code
I dont wanted to use hardcoded values in my code means
IF(LENGTH(vNewL ine) > 13) THEN ... like this
I wanted to insert '|' seperated values in my table .
cud u please tell me how to to it .
Thnaks
[CODE=oracle]
DECLARE
start_date VARCHAR2(20);
end_date VARCHAR2(20);
filename VARCHAR2(1000);
input_file utl_file.file_t ype;
input_buffer INTEGER;
vNewLine VARCHAR2(1000);
BEGIN
input_file := utl_file.fopen ('/tmp','ADDER_GEN EVA_REVENUE_REQ UEST_2310200712 1005. dat', 'R');
utl_file.get_li ne(input_file,v NewLine);
LOOP
EXIT WHEN LENGTH(vNewLine ) <= 0);
dbms_output.put _line(vNewLine) ;
IF(LENGTH(vNewL ine) > 13) THEN
start_date := SUBSTR(vNewLine ,5,8);
end_date:= SUBSTR(vNewLine ,14,8);
INSERT INTO am_test VALUES(start_da te,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;
[/CODE]
Comment