The trailing spaces going to $can make it 7 characters long.  Add this after
the split:

foreach ( $pdate, $can, $siteletter, $rtime ) { s/\s+$//; }

--
Mac :})
** I normally forward private questions to the appropriate mail list. **
Give a hobbit a fish and he eats fish for a day.
Give a hobbit a ring and he eats fish for an age.
----- Original Message -----
From: "Steve Few" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, January 26, 2002 19:58
Subject: DBD::Oracle, INSERT - stumped


> # Folks, I'm stumped on my NT4.0, ASPerl 629 build, DBI,
> # and correctly installed DBI, DBD-Oracle and DBI-Oracle8
> # my trivial script is below --- see error message please.
> # my little test data looks OK, but ?? stumped.
> # thanks in advance !  (by the way, thanks to Michael for help this
> week)
>
> -- Steve Few, NC DENR
>
> #!/usr/bin/perl -w
> use strict;
> use DBI;
> use DBD::Oracle;
> my $dbh = DBI->connect( 'dbi:Oracle:opn.ambient',
>                            'Steve',
>                            'Oracle',
>                            {
>                              RaiseError => 1,
>                              AutoCommit => 0
>                            }
>                          ) || die "Database connection not made:
> $DBI::errstr";
>  my $sql = qq/
>    INSERT INTO dat
>    (PDATE,CAN,SITELETTER,RTIME)
>    VALUES
>    ( ?, ?, ? , ? )
>  /;
>  my $sth = $dbh->prepare( $sql );
>  open( DAT, "d:/perl_resources/perlscripts/dbi/dat.prn" ) || die "Cannot
> open product file: $!";
>  while ( <DAT> ) {
>     chomp;
>  print "$_\n";
>     my ($pdate, $can, $siteletter, $rtime) = split /,/;
>     $sth->execute($pdate,$can,$siteletter,$rtime);
>   }
>  close(DAT);
> $dbh->disconnect;
>
> #__DATA___;
> # data looks like this, in flat file called dat.prn
> #Nov122, aq-xxx , ML, 33
> #Nov122, aq-xxx , ML, 33
> #Nov12 , aq-xxx , DK, 22
>
> # Oracle table looks like:
> SQL> desc dat;
>  Name                                      Null?    Type
>  ----------------------------------------- --------
> ------------------------
>  PDATE                                              VARCHAR2(12)
>  CAN                                                VARCHAR2(6)
>  SITELETTER                                         VARCHAR2(4)
>  RTIME                                              NUMBER
>
>
> ######## error message  #############
>
> D:\Perl_resources\PERLSCRIPTS\dbi>perl insert_example.pl
> Nov122, aq-xxx , ML, 33
> DBD::Oracle::st execute failed: ORA-01401: inserted value too large for
> column (DBD ERROR: OCI
> StmtExecute) at insert_example.pl line 26, <DAT> line 1.
> Issuing rollback() for database handle being DESTROY'd without explicit
> disconnect(), <DAT> li
> ne 1.



Reply via email to