LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Script for insert a lot of files in oracle database. (https://www.linuxquestions.org/questions/linux-newbie-8/script-for-insert-a-lot-of-files-in-oracle-database-4175604565/)

shirin1900 04-25-2017 07:48 AM

Script for insert a lot of files in oracle database.
 
Hello everybody,
I have a directory with a lot of log files, i want to insert the logs (*.log and *.trt.log) in database. log files are like this:

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)

I need a script that select specific files (.log and .trt_.log) and insert them into a table!!!
Any suggestion!!!
thanks for your help...

AwesomeMachine 04-25-2017 07:55 AM

Hi shirin,

Welcome to LQ.

You question is kind of wide open. Oracle has a plethora of tools to import data into a table. Do you want to put the entire log file in a field, have that field be the entire record, and the table to be single column?

shirin1900 04-26-2017 01:59 AM

hi AwesomeMachine,
thanks for your reply, i want a table with 5 column, (date_time,num_process,shell,event,comment), and i want insert a lot of file with same structure one after another in the table, something like this(example with two file, but i have more than 1000 file like this):

date_time num_process shell event comment
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)

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

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

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

12/05/2017 12:02:42 11959 trt_ret_tp STOP Chargement des fichiers HREREC (trt_ret_tp)

did i answer your question?

shirin1900 04-26-2017 02:00 AM

Quote:

Originally Posted by AwesomeMachine (Post 5701878)
Hi shirin,

Welcome to LQ.

You question is kind of wide open. Oracle has a plethora of tools to import data into a table. Do you want to put the entire log file in a field, have that field be the entire record, and the table to be single column?

hi AwesomeMachine,
thanks for your reply, i want a table with 5 column, (date_time,num_process,shell,event,comment), and i want insert a lot of file with same structure one after another in the table, something like this(example with two file, but i have more than 1000 file like this):

date_time num_process shell event comment
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)

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

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

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

12/05/2017 12:02:42 11959 trt_ret_tp STOP Chargement des fichiers HREREC (trt_ret_tp)

did i answer your question?

rtmistler 04-26-2017 06:28 AM

Quote:

Originally Posted by shirin1900 (Post 5701875)
Hello everybody,
I need a script that select specific files (.log and .trt_.log) and insert them into a table!!!
Any suggestion!!!

Hi shirin and welcome to LQ.

Please review the Site FAQ for information related to how to ask an effective question as well as how to prepare the information for your question.

Please note a few things here:
  1. You've stated your problem, updated it with additional information, and you've asked for someone to write code for you in the form of a script
  2. Members at LQ are volunteers, thus they are not paid support.
  3. The LQ site is intended to help you to learn, with the additional, and reasonable point that, it is better to have you be educated on the tools and talents necessary to complete your project. And thus your capabilities are enhanced, and perhaps in the future you can offer some of your expertise to other members in need of assistance. This is a main point of the LQ site.
  4. Therefore what to do here is to indicate what language of script you wished to code this within, and at least attempt your first script, of any nature. Other members need to know what script language you prefer, and also should get an understanding approximately what level of knowledge you have with that script language.
  5. Another part of this is to devise and post your steps to solve your problem. Citing examples and stating what you wish the outcome to be is a good starting idea, however it is best to look at general data which you can expect and write a full description of what you intend to accomplish, citing all possible input criteria, and then listing all possible outcomes you expect from that. From there you can write pseudocode which is a plain language description of the script actions you intend to fulfill.
  6. From this point you can script very effectively, and it does go back to the earlier information where you need to pick a script language and show some effort towards your goal.
  7. I'm quite sure that if you follow these guidelines and illustrate a very clear, organized description of your problem and what you feel the solution should be, as well as your attempts at a script, that LQ members will have very many suggestions to aid you with completing your project.
Best Regards


All times are GMT -5. The time now is 09:49 AM.