I'd like to write the data in a positional file. Only data which was not written before in a file will be written. Obviously, there's a column in the table to determine if the data has been written before.
In my case, say if the lenght of field is 80 but the length of data is 30 then rest of the space will be filled with spaces. For example,
----------------------------------------
| Name | SSN | Integrated |
----------------------------------------
| Doe | 453214 | Y |
| John | 1234567890 | N |
| Scarlett | 123 | N |
----------------------------------------
The first record has been transferred/written in a previous file. Hence, it will not be transferred in the next file. The length of name is fixed 80 characters. So if a name is less than 80 characters then the rest of the space will be filled by spaces. It will look something like this. Same is true for other fields
Name SSN
John 1234567890
Scarlett 123
How may I do so? Thanks in advance. Iam using oracle 11g.
EDIT
Ok, I am able to write a code. However, I would like to call this code as a procedure which I can use in dbms_jobs. The problem is that I don't know how to write a procedure.
DECLARE
v_file UTL_FILE.file_type;
BEGIN
v_file := UTL_FILE.fopen('DIR_VR_AD_INTEGRATION', 'HRMtoAD1_'||sysdate, 'w', 32767);
FOR x IN (select * from (select RPAD(user_id, 7, ' ') || ' ' || RPAD(pid_company_id, 10, ' ') str from arc_hrvr.vr_ad_integration where integrated = 'N') str where rownum <= 3 order by rownum)
LOOP
BEGIN
UTL_FILE.put_line(v_file, x.str);
END;
END LOOP;
UTL_FILE.fflush(v_file);
UTL_FILE.fclose(v_file);
END;