On Jan 7, 1:50 pm, [EMAIL PROTECTED] (John Moon) wrote: > [>>] ... > > Please try (not tested). Placeholders help me a lot: > > my $sth_insert = $dbh->prepare('Insert into info (id, name, grade, > phone, cell, house, car) > values (?,?,?,?,?,?,?)') > or die DBI->errstr; > while (<DATA>){ > > #---------------------------------------# > # Some control statements # > #---------------------------------------# > print "STEP-$stp\n"; > ($id, $name, $grade, $phone, $cell, $house, $car) = split(":"); > print "\$id = $id \n"; > [>>] ... > print "\$car = $car \n"; > print "\n"; > > [>>]die DBI->errstr unless $sth_insert->execute($id, $name, > $grade, $phone, $cell, $house, $car); > > $stp++;} > > [>>] ...
Hi John, Thanks for your reply. I tried your suggestion with the Placeholder: my $sqlInsertStmt = "insert into $table (id, name, grade, phone, cell, house, car) values (?, ?, ?, ?, ?, ?, ?)"; $sth = $dbh -> prepare ($sqlInsertStmt) || die DBI -> errstr; die DBI -> errstr unless $sth -> execute ($id, $name, $grade, $phone, $cell, $house, $car); unfortunately, I get the same error message when I run: $queryStmt = "select * from $table"; $sth = $dbh -> prepare ($queryStmt); $sth -> execute() || die "ERROR: " . DBI -> errstr(); then try to format and print the content of the fields: while (my @result = $sth -> fetchrow_array()){ #print "@result\n"; printf "%s %2d\n", "ID: ", $result[0]; printf "%s %s \n", "Name: ", $result[1]; printf "%s %d \n", "Grade: ", $result[2]; printf "%s %s \n", "Phone: ", $result[3]; printf "%s %s \n", "Cell: ", $result[4]; printf "%s %d \n", "house: ", $result[5]; printf "%s %d \n", "car: ", $result[6]; print "\n"; Only the content of the first 2 fields is displayed: ID: 2 Name: Helmut Schmidt Use of uninitialized value in printf at ./parseDataIntoDBTable.pl line 75. Grade: 0 Use of uninitialized value in printf at ./parseDataIntoDBTable.pl line 76. Phone: Use of uninitialized value in printf at ./parseDataIntoDBTable.pl line 77. Cell: Use of uninitialized value in printf at ./parseDataIntoDBTable.pl line 78. house: 0 Use of uninitialized value in printf at ./parseDataIntoDBTable.pl line 79. car: 0 Any other idea? Is there any other way to display the content of the table? Thanks for your help Berti -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/