my $sqlstr1 ="select table_name, column_name". " from Dba_tab_columns". " where owner = '$schema'". " order by table_name, column_name"; my $sth=$db->prepare($sqlstr1) or print STDOUT "Query:GetData +Failed"; $sth->execute; my $table_column = $sth->fetchall_arrayref; $sth->finish; for $table_column_r (@{$table_column}) { if ($table_column_r->[0] eq "EMP") { my $sqlstr2 =" select $table_column_r->[1]". " from $schema.$table_column_r->[0]"; my $sth=$db->prepare($sqlstr2) or print STDOUT "Query: +GetTablesColumnsData Failed"; $sth->execute; warn print STDOUT "\n***Error*** Table: $table_column_ +r->[0] Column: $table_column_r->[1] \n", $sth->errstr(), "\n" if $sth->err(); warn print SUMMARY "\n***Error*** Table: $table_column +_r->[0] Column: $table_column_r->[1] \n", $sth->errstr(), "\n" if $sth->err(); my $column_data = $sth->fetchall_arrayref; $sth->finish; # This for-loop create a hash of a hash of an array wi +th the keys {table name} and {column name} for $row (@{$column_data}) { push (@{$tables{$table_column_r->[0]}{$table_colum +n_r->[1]}}, $row->[0]); # To print value of hash: p @{$tables{$table_colum +n_r->[0]}{$table_column_r->[1]}} } undef @data_array; } }
In reply to Database Table to Hash of Hash of Array by timo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |