Home » SQL & PL/SQL » SQL & PL/SQL » Load Log file into Oracle
Load Log file into Oracle [message #191072] Mon, 04 September 2006 06:15 Go to next message
MattJ83
Messages: 4
Registered: September 2006
Location: London
Junior Member
hi,

Im having trouble loading a .log file into oracle. I can connect to the
database and i can insert data (that i define in an INSERT statement).
I eventually need to filter specific info from the .log files (there
are alot of them - and this script provides an automated process) but
for now i just want to read the whole script into a table!


CURRENT SCRIPT:
#!/usr/central/bin/perl -w


use strict;
use DBI;


my $dbh = DBI ->connect("dbi:Oracle:SERVER", "DATABASE", "PASSWORD")
or die "Couldn't connect to database: $DBI::errstr\n";


my $rows = $dbh->do("
INSERT INTO LOGS VALUES ('160820061-fst.log', '5', '0', 'FASTSEARCH',
'0', 'inversions', '0', 'conflicting') ");


$dbh->disconnect;


exit;

##### I have also tried the following and putting $LOG into one of the
values but I just get the value '1' returned!
my $LOG = open (LOG, "/home/USRNAME/PERL/hello.log");


my @data = <LOG>;
close LOG;


Any ideas?


Thanks


Re: Load Log file into Oracle [message #191073 is a reply to message #191072] Mon, 04 September 2006 06:29 Go to previous messageGo to next message
ThomasG
Messages: 3189
Registered: April 2005
Location: Heilbronn, Germany
Senior Member

>but I just get the value '1' returned!

Yes, presumably because the insert statement inserted '1' row. So '1' is returned as result of the statement.

Have you checked what's in the LOGS table after the script has run?

Re: Load Log file into Oracle [message #191084 is a reply to message #191073] Mon, 04 September 2006 07:40 Go to previous messageGo to next message
MattJ83
Messages: 4
Registered: September 2006
Location: London
Junior Member
My code is now:

#!/usr/central/bin/perl -w

use strict;
use DBI;

#!/usr/central/bin/perl -w

use strict;
use DBI;

my $dbh = DBI ->connect("dbi:Oracle:SERVER", "DATABASE", "PASSWORD")
or die "Couldn't connect to database: $DBI::errstr\n";

my $LOG = open (LOG, "/home/USERNAME/PERL/hello.log");

my @data = <LOG>;
close LOG;

my $rows = $dbh->do("
INSERT INTO LOGS VALUES ( 'wesdf', 'sdfg', 'dfg', 'fdg', 'dfg', 'dfg', 'dfg', 'dfg', $LOG) ");

$dbh->disconnect;

exit;


where the value $LOG is to be inserted I get 1 still...im using TOAD so can lookup the table as soon as i have executed the script.....im expecting the hello.log to be placed in the last field - a CLOB field.

Matt
Re: Load Log file into Oracle [message #191093 is a reply to message #191072] Mon, 04 September 2006 10:03 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
1) This question has NOTHING to do with SQK or PL/SQL.
2) $LOG is nothing more than a file handle & will NEVER contain the contents of the file as coded.
3) Please take this post over to any PERL forum.
Re: Load Log file into Oracle [message #191099 is a reply to message #191093] Mon, 04 September 2006 10:22 Go to previous messageGo to next message
MattJ83
Messages: 4
Registered: September 2006
Location: London
Junior Member
It does have some relation to SQL though - and being new to this kind of script and oracle - thought I might get some productive answers.....for instance, is INSERT the right SQL statement to be using in this instance or could i use something like copy?

However, I apologise if i offended you.
Re: Load Log file into Oracle [message #191102 is a reply to message #191072] Mon, 04 September 2006 10:43 Go to previous messageGo to next message
BlackSwan
Messages: 25046
Registered: January 2009
Location: SoCal
Senior Member
>could i use something like copy?
COPY?
COPY is NOT part of the SQL language either.
Your problem has little to do with SQL & everything to do with PERL.
Re: Load Log file into Oracle [message #191103 is a reply to message #191099] Mon, 04 September 2006 10:58 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
I don't know perl, but this looks different than your code.
Re: Load Log file into Oracle [message #191198 is a reply to message #191103] Tue, 05 September 2006 02:53 Go to previous message
MattJ83
Messages: 4
Registered: September 2006
Location: London
Junior Member
Anacedent:
'Your problem has little to do with SQL & everything to do with PERL'.
This is all I needed to know - thanks, now I know that my problem is more PERL based. As I said - I hope i didn't offend you - getting technical knowledge in one form or the other is always helpfully - even if i was in the wrong place!

Thanks for that link Frank - i'd already been on that site to be honest - its similar to my code - just written in a different way!
Previous Topic: OUT JOIN
Next Topic: Y is this not working..Urgent ..Plz
Goto Forum:
  


Current Time: Thu Dec 08 04:06:53 CST 2016

Total time taken to generate the page: 0.11723 seconds