substr means substring - it extracts a short string from a longer one
instr means in string - it returns the position a string starts in another string
BEGIN
Start of code block
FOR b IN 1..20 LOOP
Loop incrementing b from 1 to 20
UTL_FILE.GET_LINE (fp,v_line);
Read a line from the file pointed to by fp into v_line
IF SUBSTR(v_line,1,3) = '***'
If the first three characters are asterixs...
AND :DETAIL.FILE_DATE IS NULL THEN
and this field is null...
:DETAIL.FILE_DATE := substr(v_line,1,100);
set the field to the first 100 characters of v_line
END IF;
END LOOP;
IF :DETAIL.FILE_DATE IS NULL THEN
:DETAIL.FILE_DATE := v_temp_line;
END IF;
v_temp_line := TO_CHAR(SYSDATE,'YYYY');
set v_temp_line to the current year (2006)
IF instr(:DETAIL.FILE_DATE,v_temp_line) >0 THEN
If the file_date contains the current year
:DETAIL.FILE_DATE := SUBSTR(:DETAIL.FILE_DATE,instr(:DETAIL.FILE_DATE,v _temp_line),16);
set file_date to 16 characters from the position of the current year
(If file_date = 'this is junk 2006/10/04 10:24 shakespeare', it will become
'2006/10/04 10:24')
v_temp_date := TO_DATE(:DETAIL.FILE_DATE,'YYYY-MM-DD HH24:MI');
Convert string to date
v_temp_line := TO_CHAR(v_temp_date,'DD Mon YYYY HH24:MI');
convert date to new string format (10-04-2006 10:24 -> 10 Apr 20006 10:24)
:DETAIL.FILE_DATE := v_temp_line;
END IF;
UTL_FILE.FCLOSE(fp);
closes the file
IF v_temp_date > (:header.sysdate - :header.filter_days) THEN
get_file_size;
I hope this helps - but try technet.oracle.com for complete documentation of Oracle.
Regards,
Tom
|