This is kind of a newbie question.

I am collecting statistics from a database for data profiling.
I have created a 4 deep hashes within hashes to hold those stats, as such:
$a={NUM_NULL => 0, DISTINCT => 150, NUM_ROWS => 2000}; $b={PRO_NUMBER => \%a}; $c={AC_SHIPMENT => \%b}; %Profileshoh = (IC_STAGE => \%c);

While I have good success obtaining the statistics, I am only getting the last value loaded into the hash structure back when I attempt to print it out.

I suspect my problem is in the loop where I am loading the data. I think I may be re-defining the whole hash at that point, but I can't find an example that shows me what I want to do.

code after readmore
#!/usr/bin/perl -w use DBI; $dbh = DBI->connect("dbi:Oracle:XXXX","XXXXXX","XXXX", { AutoCommit => 0, RaiseError => 1, PrintError => 1 }) or die "can't connect to database:", $DBI::errstr, "\n"; $sth = $dbh->prepare("select 'IC_STAGE', t.table_name, column_name from user_tables t, user_tab_columns c where c.table_name = t.table_name AND t.table_name = 'AC_SHIPMENT' AND column_name in ('ACT_DELIVERY_TSP', 'CONS_NATL_ACCT_NBR', 'PICKUP_UNIT_ID')"); $sth->execute(); while (@row = $sth ->fetchrow_array()) { push @ListoTabCols, [@row]; } $dbh ->disconnect(); print "disconnected\n"; for $i ( 0 .. $#ListoTabCols ) { print "reconnecting\n"; $dbh = DBI->connect("dbi:Oracle:XXXX","XXXX","XXXX", { AutoCommit => 0, RaiseError => 1, PrintError => 1 }) or die "can't connect to database:", $DBI::errstr, "\n"; $prow = $ListoTabCols[$i]; print "row $i : $prow->[0] $prow->[1] $prow->[2]\n"; @returno = $dbh->selectrow_array("select min($prow->[2]) from $pro +w->[1]"); $dbh ->disconnect(); print "disconnected\n"; # HERE IS THE INSERT INTO THE HASH ************* print "returned value: $returno[0]\n"; %Profileshoh = ($prow->[0] => { $prow->[1]=>{ $prow->[2]=>{ MIN_VALUE=>$returno[0] } } }) } while ( ($schemata, $tablas) = each %Profileshoh ) { print "$schemata: "; while ( ($tabla, $colums) = each %$tablas ) { print "$tabla: "; while ( ($colum, $measures) = each %$colums ) { print "$colum: "; while ( ($measure, $value) = each %$measures ) { print "$measure = $value "; } } } print "\n"; } exit;

In reply to insert data into Nested Hash by poqui

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.