1 Reply Latest reply: May 19, 2011 7:07 AM by Paul M. RSS

    Insert into a table using UNIX

    Depakjan
      i have file Summary.txt

      contants looks like this

      ./log_CS-185.lst:Error detected, rollbacking
      ./log_CS-13603.lst:Error detected, rollbacking
      ./log_CS-1002.lst:Error detected, rollbacking

      now i have to parse this file to get (CS-185,CS-13603,CS-1002)

      and insert these vlaues into a table... how do i do this using unix script ?..
        • 1. Re: Insert into a table using UNIX
          Paul M.
          i have to parse this file to get (CS-185,CS-13603,CS-1002)

          and insert these vlaues into a table... how do i do this using unix script ?..
          Example :
          $ cat read_Sum.sh
          cat Summary.txt | while read LINE
          do
                  VAR=`echo $LINE | awk -F_ '{print $2}' | awk -F. '{print $1}'`
                  echo $VAR
                  sqlplus -s test/test << EOF
                  insert into summary values('$VAR');
                  exit
          EOF
          done
          $ ./read_Sum.sh
          CS-185
          
          1 row created.
          
          CS-13603
          
          1 row created.
          
          CS-1002
          
          1 row created.
          
          $ sqlplus test/test
          
          SQL*Plus: Release 10.2.0.3.0 - Production on Thu May 19 13:32:40 2011
          
          Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
          
          
          Connected to:
          Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
          With the Partitioning, OLAP and Data Mining options
          
          SQL> select * from summary;
          
          CODE
          --------------------------------------------------
          CS-185
          CS-13603
          CS-1002
          
          SQL>