2

I have , for instances 4 csv files in a directory with 3 columns each one, but the name of the file contains the date and time and I need to add these information (date and time) to 2 new columns in the external tables. Is there some way to do that directly in Oracle without having to prepare the csv files adding the new columns on them (parsing the name and extracting the date and time)

Thanks

Laerte Junior
  • 244
  • 3
  • 16
  • 2
    [Something like this](https://stackoverflow.com/a/29106343/266304) maybe? You could extract only the relevant part of the filename instead of the whole thing. That doesn't modify the actual files, just what the driver sees; but does still involve parsing. (Which operating system is the DB running on? That example is a Unix shell script; I guess you can do the same with PowerShell on Windows....) – Alex Poole Apr 26 '18 at 11:52
  • Right..but you are changing the original file to add the name of the file in the csv file right ? – Laerte Junior Apr 26 '18 at 11:55
  • Nope. Doesn't modify the file. The preprocessor appends the file name using `printf` to standard output, and [the driver reads that instead](https://docs.oracle.com/en/database/oracle/oracle-database/12.2/sutil/oracle_loader-access-driver.html#GUID-73A6DA8D-EA78-4B9B-BAB3-0C99BF190A50) of the actual file(s). – Alex Poole Apr 26 '18 at 11:57
  • Awesome. I am usinng wiindows. Does it works with Powershell :? – Laerte Junior Apr 26 '18 at 11:58
  • That exact syntax won't, no; you need an equivalent script. (I don't know it well enough to convert without some experimentation, and don't have time for that at the moment I'm afraid. I imagine/hope it's possible though.) – Alex Poole Apr 26 '18 at 12:00
  • Thanks Alex I will try with PowerSHell :) – Laerte Junior Apr 26 '18 at 12:02

0 Answers0