Wednesday 18 August 2021

List of files in Linux to be stored in Oracle database table

 We can use external table as below:

CREATE TABLE GLFILESLIST

(

  FILE_NAME  VARCHAR2(1000 BYTE)

)

ORGANIZATION EXTERNAL

  (  TYPE ORACLE_LOADER

     DEFAULT DIRECTORY CONC_OUT_DIR

     LOCATION (CONC_OUT_DIR:'glFilesList.dat')

  )

REJECT LIMIT UNLIMITED;



In Linux shell:

ls -ltrA gl_import | awk '{print $9}'| tail -n +2   > glFilesList.dat

We can put the above command to refresh the list based on 5 minutes frequency as below:

*/5 * * * *  ls -ltrA gl_import | awk '{print $9}'| tail -n +2   > glFilesList.dat


The output will be stored in glFilesList.dat and later will be a source for the table




2 comments:

Number of Visitors