Use trace. Use trace. Use trace. Tim.
On Wed, Sep 18, 2002 at 02:35:02PM -0400, Dolan, Mark wrote: > I am trying to update a table in an Oracle database. I am reading an > input file which has > the column names for the database as the first record in the file. The > data begins in the second row. I read the first record to pull off the > column names. I create the sql using placeholders. I then read the rest > of the file. At the end of the loop I attempt to perform the 'execute' > using the statement handle of the database. I get the following error. > > DBD::Oracle::st execute failed: ORA-01722: invalid number (DBD ERROR: > OCIStmtExecute) at ./ins line 61, <$FH> line 1. > > At the time of the execute @ins = "20", "00002", "Hello, Dolly", "000", > "01", "022" > > > # assume sth is a valid statement handle > # assume $FH is a handle to an opened file > my $columns = <$FH>; > # > # read first record of input file > # split the column headers > # > my $columnitem; > chomp($columns); > @ins = split /\|/, $columns; > foreach $columnitem (@ins) { > $columnitem = "\"".$columnitem."\""; > } > my $formatcolumns=join ( ', ', @ins ); > my $valstring= join ( ', ' , ('?') x scalar @ins ); > my $sql= "INSERT INTO $table ( $formatcolumns ) VALUES ( $valstring) "; > while ( my $line = <$FH> ) > { > # > # split the data fields > # > chomp($line); > my $field; > @ins = split /\|/, $line; > foreach $field (@ins) { > $field = "\"".$field."\","; > } > chop($ins[-1]); # remove comma from last item in array > #the actual sequence > $sth->execute(@ins) or $err++; > } >