in reply to Re: Using a multi-level hash in an insert statement...
in thread Using a multi-level hash in an insert statement...
Will cause transposing (e.g. '20050101' to be stored as 'name') of the key/values in the insert, because you can't rely on the order that keys() returns.$sth->bind_param( $i++, $holidays->{$name}->{$_} ) foreach keys %{$hol +idays->{$name}};
$sth->bind_param( $i++, $holidays->{$name}->{$_} ) foreach qw/ name da +te type federal active /;
use SQL::Abstract; my $sql = SQL::Abstract->new; while( my ($name,$data) = each %holidays ) { my %data = ( %$data, name => $name ); # assuming hash only has key +s corresponding to cols in table my($stmt, @bind) = $sql->insert('your_table_name', \%data); $dbh->do($stmt, {}, @bind); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Using a multi-level hash in an insert statement...
by Transient (Hermit) on Apr 21, 2005 at 15:09 UTC |