If you are loading a large file to Informix and want to avoid the
overhead of doing many inserts, you can call dbaccess from a system call

and pipe commands to it (see below).  Otherwise, you need to loop and
insert each row individually.

While I love DBI, doing inserts just isn't as fast as running a bulk
loader, which is what you are doing when you run dbaccess in this
fashion.

Please recognize this is "off the top of my head code" and will not run
as is, but it'll give you an idea as to "how-to".

with DBI:
my $sth= $dbh->prepare("insert into my_table VALUES ?,?,?");#or however
many placeholders you need
while(<INFILE>){
    my @row = split($mydelimiter, $_);
    $sth->execute(@row);
}



With DB-Access:

`$INFORMIXDIR/bin/dbaccess $DATABASE <<! 2>>$logfile

set isolation dirty read;

load from file "$outfile"
#your insert statement here#

!`;

"Wilson, Doug" wrote:

> 'LOAD ...' is not a sql statement. It is a dbaccess/4GL
> feature. It does not even work from ESQL/C (which is where
> it would have to work from in order to work from DBI/DBD::Informix).
>
> There are plenty of workarounds. Select/fetch your data
> into an array, join it with a delimiter, and print it, e.g.
> 'print join("|", @array),"\n";'
>
> Cheers,
> Douglas Wilson
>
> > -----Original Message-----
> > From: Mahdi A. Sbeih [mailto:[EMAIL PROTECTED]]
> > Sent: Monday, July 16, 2001 7:08 AM
> > To: Jonathan Leffler
> > Cc: Dbi-Users; DBD Informix Maintenance Team
> > Subject: Using Informix LOAD and UNLOAD from DBD::Informix
> >
> >
> > Hi all,
> >
> > I am trying to load data into tables using LOAD statement,
> > and I am getting a syntax error from this:
> >
> > $db_handle->do("load from file insert into mytable")
> >
> > I spent an hour investigating this, until I found out
> > that LOAD and UNLOAD statements can only
> > be used from Informix DBAccess, this was a shock for me :-( .
> >
> > Is there any work around, I will not be happy using DBAccess
> > since I don't want to use any system calls.
> >
> >
> >
> >
> > Thanks in advance,
> > regards,
> > Mahdi.
> >
> >
> >
> >
> >
> > _____________________
> > Mahdi A. Sbeih
> > Software Engineer
> > IDS Software Systems
> > [EMAIL PROTECTED]
> > _____________________
> >

Reply via email to