Hello: On Wed, Jul 20, 2011 at 12:45 PM, Mohan L <l.mohan...@gmail.com> wrote: > It trying to store that string into the first column and nothing into > the subsequent columns. That is why it shows "column cannot be null" > error messages. Thanks Jim Gibson!!!. > > Jim Gibson, I understand the problem, but I not sure where in the below > code I am making mistake .
I'm not sure what you're trying to do there. :P The 'join' seems to be the root of the problem, but I'm not even going to attempt to figure it out. You need to turn a hash into an array (reference). Simplest way is perhaps a hash slice. use strict; use warnings; use Data::Dumper; my %data = ( south => { status => { open => { count => 3 }, pws => { count => 3 }, wip => { count => 0 }, hold => { count => 1 }, 're-open' => { count => 0 }, pwu => { count => 0 }, openesc => { count => 0 }, }, total_count => 7, }, north => { status => { open => { count => 3 }, pws => { count => 0 }, wip => { count => 0 }, hold => { count => 7 }, 're-open' => { count => 0 }, pwu => { count => 0 }, openesc => { count => 0 }, }, total_count => 10, }, ); # This will be the data to execute the query with. my @rows; for my $region (keys %data) { my $status = $data{$region}->{status}; # Slice of hash referenced by $status. my @statuses = @{$status}{qw( open pws wip hold re-open pwu openesc)}; # Map each status hash to the count inside. my @counts = map { $_->{count} } @statuses; # Create an array reference of the row, with the region name, # counts, and total. my $row = [$region, @counts, $data{$region}->{total_count}]; push @rows, $row; } print Data::Dumper->Dump([\@rows], ['rows']); __END__ Output: $rows = [ [ 'south', 3, 3, 0, 1, 0, 0, 0, 7 ], [ 'north', 3, 0, 0, 7, 0, 0, 0, 10 ] ]; HTH. -- Brandon McCaig <http://www.bamccaig.com/<bamcc...@gmail.com> V zrna gur orfg jvgu jung V fnl. Vg qbrfa'g nyjnlf fbhaq gung jnl. Castopulence Software <http://www.castopulence.org/<bamcc...@castopulence.org> -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/