Yes. While the soolution below is correct it might help to tell the person
who oringally posted this question why they where getting an error.

The difference is in:

$sth = $dbh->do("insert "....
$sth->bind_param(" ...

and

$sth = $dbh->prepare("insert....
$sth->bind_param(" ...

Essentially the previous code is trying to bind an input paramter to a
statement that is already executing and therefore is an error.

The RaiseError attribute should be set when in doubt about where and error
is coming from and you can always use DBI->trace.

--Neil

>
>$insert_sql = <<EOT
>Insert into ofas
>(company,time,region,lineitem,actual,actualus)
>values (?,?,?,?,?,?)
>EOT
>
>$sth = $dbh->prepare($insert_sql) || die $dbh->errstr;
>
>while ($line = <tmptestper>) {
>
>   # your unpack and other stuff here
>
>
>   $sth->bind_param(1,$company);
>   $sth->bind_param(2,$year);
>   $sth->bind_param(3,$region);
>   $sth->bind_param(4,$lineitem);
>   $sth->bind_param(5,$actual);
>   $sth->bind_param(6,$actualus);
>   $sth->execute || die $sth->errstr;
>
>   $dbh->commit;  # autocommit on?
>}
>
>
>----- Original Message ----- 
>From: "Anurag Minocha" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Friday, August 03, 2001 9:48 AM
>Subject: Perl.exe generating errors when used on Win 2K
>
>
>> 
>> Hi,
>> I have Perl installed on my windows 2000 machine but when I 
>execute a perl
>> dbi script windows gives me a program error.
>> 
>> Here is the error
>> Perl.exe has generated errors and will be closed by windows. 
>You will need
>> to restart the program. An error log is being created.
>> 
>> Here is the script I am trying to execute
>> 
>> #! c:\perl\bin 
>> use dbi;
>> 
>> my $dbh =
>> DBI->connect("dbi:Oracle:local_orcl8i","localcompany","localcompany")
>> or die "Can't Connect to Oracle Database $DBI::errstr\n";
>> 
>> 
>> open (tmptestperl , "testperl.txt") or die "Cant Open 
>testperl.txt \n";
>> 
>> while ($line = <tmptestperl>) {
>> ($company,$year,$region,$lineitem,$actual,$actualus) =
>> unpack("A10 X A10 X A10 X A15 X A20 X A*", $line);
>> 
>> $actual =~ s/,//g;
>> $actual =~ s/NA//;
>> 
>> $actualus =~ s/,//g;
>> $actualus =~ s/NA//;
>> 
>> $sth = 
>> $dbh->do(" Insert into ofas
>> (company,time,region,lineitem,actual,actualus)
>> values (?,?,?,?,?,?)");
>> 
>> $sth->bind_param(1,$company);
>> $sth->bind_param(1,$year);
>> $sth->bind_param(1,$region);
>> $sth->bind_param(1,$lineitem);
>> $sth->bind_param(1,$actual);
>> $sth->bind_param(1,$actualus);
>> 
>> 
>> print "$actual \n";
>> 
>> 
>> 
>> }
>> 
>> This script was working fine insert and bind variable 
>statements. i.e when I
>> wasnt trying to insert into the database.
>> 
>> Please Suggest something
>> 
>> Thanks
>> Anurag
>> 
>

__________________________________________________________________________
Please Note :
Only  the intended recipient is authorised to access or use this e-mail.
If you are not the intended recipient, please delete this e-mail and notify
the sender immediately. The contents of this e-mail are the writer's 
opinion and are not necessarily endorsed by the Gunz Companies
unless expressly stated.

We use virus scanning software but exclude all liability for viruses or
similar in any attachment.


Reply via email to