in reply to perl mysql - INSERT INTO, 157 columns
(updated to anonymize the table name)my $sth = $db->prepare( "describe my_big_table" ); $sth->execute; my $rows = $sth->fetchall_arrayref; $sth->finish; my @column_names = map { $$_[0] } @$rows; my $insert_sql = join( '', 'insert into my_big_table (', join( ',', @column_names ), ') values (', join( ',', ( '?') x scalar @column_names ), ')' ); # check your work, if you like: print join( "\n", "=== columns:", @column_names, '=== sql:', $insert_s +ql, '' );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: perl mysql - INSERT INTO, 157 columns
by Tux (Canon) on May 02, 2014 at 12:35 UTC | |
by graff (Chancellor) on May 02, 2014 at 16:52 UTC | |
by choroba (Cardinal) on May 02, 2014 at 17:03 UTC | |
by gsiems (Deacon) on May 02, 2014 at 18:17 UTC | |
by erix (Prior) on May 02, 2014 at 12:53 UTC | |
by Tux (Canon) on May 02, 2014 at 14:57 UTC | |
by erix (Prior) on May 02, 2014 at 19:25 UTC | |
by Tux (Canon) on May 03, 2014 at 12:52 UTC |