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: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).

Reply via email to