0

I have a lot of log files that i want to insert them into a table (oracle). What is the best to do so?

All logs are like below. There are lot of files like this in my directory.

11/04/2017 12:00:02 11959 trt_ret_tp      START         Chargement des fichiers HREREC (trt_ret_tp)

11/04/2017 12:00:02 11959 trt_ret_tp                    Aucun fichier ▒ traiter

11/04/2017 12:00:02 11959 trt_ret_tp                    Mise a jour de la date de dernier recouvrement

11/04/2017 12:02:42 11959 trt_ret_tp      STOP          Chargement des fichiers HREREC (trt_ret_tp)
Utsav
  • 7,914
  • 2
  • 17
  • 38
sh1900
  • 1
  • 1) Why do you need this in database, and not let it be in Unix? 2) If you want to enter log values to database, then try doing it at code level if that is not very difficult, as log format can change if your code changes. 3) If you still want to do it, then google about `sqlloader`. – Utsav Apr 24 '17 at 12:45
  • Can you give me your opinion for the answer that i send, please? – sh1900 Apr 25 '17 at 10:08
  • Try running it in your dev environment and see what error do you get. – Utsav Apr 25 '17 at 11:00
  • and also can you give me some piste about change in code level, please? – sh1900 Apr 25 '17 at 12:16

2 Answers2

0

You need a loop to iterate all your tree folder and then you need to read each line of the log file and then create the sql INSERT sentence for that line. That should be easy, i dont have a Oracle instance to make an example, but try to do it with this hint.

AFR
  • 105
  • 4
0

Is this solution correct?

Create table CREATE TABLE "LOG_GAM_NOY" ( "DATE", DATE NOT NULL ENABLE, "TIME", VARCHAR2(8) DATE NOT NULL ENABLE, "NUM_OF_PROCESS" NUMBER(8), "SHELL" VARCHAR2(20 BYTE), "EVENEMENT" VARCHAR2(20 BYTE), "LIBELE" VARCHAR2(200 BYTE), ) ;

Control file OPTIONS LOAD DATA INFILE /donnees/gam/log/*.log INFILE /donnees/noyau/log/*.log REPLACE INTO TABLE LOG_GAM_NOY FIELDS TERMINATED BY X’9’
TRAILING NULLCOLS (DATE,TIME,NUM_OF_PROCESS,SHELL,EVENEMENT,LIBELE) )

sh1900
  • 1