in reply to Need help with Insert

If your @row has 30 elements, there will be no $row[30]. The last one will be $row[29]. Maybe you would rather do:
my $sthsql = $mysql_dbh1->prepare("INSERT INTO r501 (reg, pat, ped, ad +nasec, impexp, cveped, adnaent, crupimp, rfcimp, curpaa, tc, flete, s +eguro, embal, oincrem, odeduc, pesob, transal, tranarr, travent, dest +ino, nomimp, calleimp, numimp, numext, cp, mcpio, entfed, paisimp, ar +chivo) VALUES (?)") $sthsql->execute( join(', ' , @row) );
-driver8

Replies are listed 'Best First'.
(Re^2: Need help with Insert) Joining bind values doesn't work
by Narveson (Chaplain) on Mar 14, 2008 at 04:34 UTC

    Did you test this?

    I had to insert the missing semicolon in order to test

    $sthsql->execute( join(', ' , @row) );
    and then I got
    execute failed: There are more columns in the INSERT statement than values specified in the VALUES clause. The number of values in the VALUES clause must match the number of columns specified in the INSERT statement.

    What happens is that DBI spots the imbedded quotes in the joined string and cleverly escapes them.

    See also Can a DBI Placeholder accept multiple values?

      No, I didn't test it. I don't have a lot of DBI experience, and I don't have a DB running at the moment. Thanks for pointing out the error and the right way to do it. -driver8