in reply to variable type

So now I have a new problem. I am writing an insert_row function. I do not know how many columns I will be inserting, how would I dynamically handle the call to $sth->execute? The DBI documentation offers up this nice example, but how would I change it to handle a dynamic number of columns?
my $sth = $dbh->prepare(q{ INSERT INTO sales (product_code, qty, price) VALUES (?, ?, ?) }) or die $dbh->errstr; while (<>) { chomp; my ($product_code, $qty, $price) = split /,/; $sth->execute($product_code, $qty, $price) or die $dbh->errstr; } $dbh->commit or die $dbh->errstr;

Replies are listed 'Best First'.
Re^2: variable type
by chromatic (Archbishop) on Dec 07, 2006 at 19:16 UTC

    DBI is OK has some sample code you might enjoy.