Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Mailing Lists -> Oracle-L -> Re: Data integration script using PERL

Re: Data integration script using PERL

From: Jared Still <jkstill_at_cybcon.com>
Date: Fri, 16 Nov 2001 08:35:40 -0800
Message-ID: <F001.003C7762.20011116074026@fatcity.com>

Hmm, no one ever asks for loaders, as sqlloader does a pretty good job of that. What everyone always asks for is an unloader. ( coming up, easier than you think :)

Loading is pretty straightforward.

If you have the column names as the first row, even better. ( this is bare bones. you fill in error checking, database connection, etc )

#Assume double quotes and commas delimited

open(DATA, "mydata.txt");

my $line = <DATA>;
chomp $line;
$line =~ s/\"//g;

my @columns = split(/\,/, $line);

my $insert = qq{ insert into mytable ( $line ) values ( } .

    join(',' '?' x $#columns +1) . q{)};

my $sth = $dbh->prepare($insert);

while(<DATA>) {

   chomp;
   @columns = split(/,/);
   $sth->execute(@columns);
}

$dbh->commit;

Any more than this and you should really join the DBI users list, which can be found at lists.perl.com

Jared

On Wednesday 14 November 2001 05:15, ALEMU Abiy wrote:
> Is there someone who wrote a script in a PERL language designed to insert
> data in Oracle tables by reading data from a text data file ? If so, is it
> possible to have just an example of it so that I can adapt it for my need.
> Just not to reinvent the wheel ....
>
> Thanx


Content-Type: text/html; charset="iso-8859-1"; name="Attachment: 1"
Content-Transfer-Encoding: 7bit
Content-Description: 
----------------------------------------
-- 
Please see the official ORACLE-L FAQ: http://www.orafaq.com
-- 
Author: Jared Still
  INET: jkstill_at_cybcon.com

Fat City Network Services    -- (858) 538-5051  FAX: (858) 538-5051
San Diego, California        -- Public Internet access / Mailing Lists
--------------------------------------------------------------------
To REMOVE yourself from this mailing list, send an E-Mail message
to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
the message BODY, include a line containing: UNSUB ORACLE-L
(or the name of mailing list you want to be removed from).  You may
also send the HELP command for other information (like subscribing).
Received on Fri Nov 16 2001 - 10:35:40 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US