http://qs321.pair.com?node_id=255230


in reply to Extracting data from a pipe delimited text file into a table in Access

I don't know what Access is complaining about but here's some hints to clean up your code.

# !/usr/bin/perl -w use strict; use DBI qw(:sql_types); my $dsn = "dbi:ODBC:Daily_Rec"; my $dbh = DBI->connect($dsn,'','', {RaiseError=>1,PrintError=>1,AutoCommit=>1} ); open(DAT, "c:/Temp/heldreceipts_TempFile.txt") or die "could not open Held Receipts file: $!"; my $query = qq{insert into Held_Receipts values (?,?,?,?,?,?,?,?)}; my $sth = $dbh->prepare($query) or die "cannot prepare query: $DBI::errstr"; while(<DAT>) { chomp; my @line = split /\|/; $sth->execute(@line) or die "Execute error: $DBI::errstr"; } $sth->finish(); $dbh->disconnect();

Update: I think TVSET's advice is good. If you can, attempt to run the statement through some other interface and see if it complains, too.

90% of every Perl application is already written.
dragonchild

Replies are listed 'Best First'.
Re: Re: Extracting data from a pipe delimited text file into a table in Access
by Anonymous Monk on May 05, 2003 at 13:14 UTC
    Thanks for your help! when i run your script i dont get any errors and the table does not get populated.
    also when i print out $query
    i get:
    insert into Held_Receipts values (?,?,?,?,?,?,?,?)
    any help would be greatly appreciated!!