I am using SQL Loader to import data from CSV file to a database table, and it works fine. Each time I run the command sqlldr, the log file is overridden with new infos. Is there a way to add a timestamp or something to keep the archive of those log files instead of overriding the same file and without passing the value in the command params.
CONTROL=D:\projects\ctl\control.ctl
LOG=D:\projects\log\TRACK_MIGRATION.log
DATA=D:\projects\data\CUSTOMERS_SITES.csv
Want something like : TRACK_MIGRATION_20221229_113917.log
After a long search, found no native way to automate naming the SQL Loader log file by adding a timestamp or something.
As mentioned above, I suggest wrapping the command line in a script that will take the responsibility of renaming your log file after it gets generated, or using the log=
command line param which is a bit frustrating if you are running your command often.
For my case I found that our client use VBScript for such things in the server, so I decided using it to wrap my command line.
'Running SQL Loader command line
Dim oShell
Set oShell = WScript.CreateObject("WScript.Shell")
oShell.run "sqlldr userid=" & DBLogin & "/" & DBPwd & "@" & DBName & " parfile=parfile.par"
Set oShell = Nothing
'Renaming the log file (TRACK_MIGRATION_YYYYMMDD_HHMMSS.log)
Dim FSO
Dim todayDate
todayDate = Year(Now) & Month(Now) & Day(Now) & "_" & Hour(Now) & Minute(Now) & Second(Now)
Set FSO = CreateObject("Scripting.FileSystemObject")
FSO.MoveFile "TRACK_MIGRATION.log", "TRACK_MIGRATION_" & todayDate & ".log"