
britantyo
Novice
Jun 21, 2010, 1:36 PM
Post #1 of 2
(7682 views)
|
getting out ref array inside array?
|
Can't Post
|
|
hey perlguru. this is my first post, glad to find this kind of forum. i hope we can help each other and share on perl. okay. i'm a very beginer of perl i admit it , so perlguru, make me an expert so i can help others. here is my problem : - my dump result is { DESTINATION_ID => undef, ISSUER_ID => "PANIN", ORIGINATOR_ID => "MAESTRO", PROD_TYPE => "MD", SUMM_AMOUNT => { CNY => "", EGP => "", HKD => "", IDR => "", KRW => "", MYR => "", SAR => "", SGD => "" }, SUMM_FREQ => { CNY => 10, EGP => 1, HKD => 2, IDR => 260, KRW => 2, MYR => 11, SAR => 2, SGD => 3 }, TO_ISSUER => "", TRX_DESC_TITLE => "INQUIRY", }, { DESTINATION_ID => "ALTO", ISSUER_ID => "ANY", ORIGINATOR_ID => undef, PROD_TYPE => "AT", SUMM_AMOUNT => { IDR => "", USD => "" }, SUMM_FREQ => { IDR => 1054, USD => 3 }, TO_ISSUER => "", TRX_DESC_TITLE => "INQUIRY", }, these result is taken from my script after i "fetchrow hashref" from DB then i put it in array. you can see that there is array variable inside array (see the bold line). yes i'm using reference for every value. but what if i want to capture the reference namein the second array? is there a way to do it? here is the script's slice of mine my $itemNo = 1; my $trxGroupID = 0; my @trxGroups = (); $sql = "SELECT TRX_GROUP_ID, ISSUER_ID, TO_ISSUER, PROD_TYPE, ORIGINATOR_ID, DESTINATION_ID, TRX_DESC_TITLE FROM FX_TRX_GROUP ORDER BY TRX_GROUP_ID"; $sth = KAB_Util->ExecQuery($dbh, $sql); while ($row = $sth->fetchrow_hashref()) { $trxGroupID = $row->{'TRX_GROUP_ID'}; $trxGroups[$trxGroupID]{'ISSUER_ID'} = $row->{'ISSUER_ID'}; $trxGroups[$trxGroupID]{'TO_ISSUER'} = $row->{'TO_ISSUER'}; $trxGroups[$trxGroupID]{'PROD_TYPE'} = $row->{'PROD_TYPE'}; $trxGroups[$trxGroupID]{'ORIGINATOR_ID'} = $hosts{ $row->{'ORIGINATOR_ID'} }; $trxGroups[$trxGroupID]{'DESTINATION_ID'} = $hosts{ $row->{'DESTINATION_ID'} }; $trxGroups[$trxGroupID]{'TRX_DESC_TITLE'} = $row->{'TRX_DESC_TITLE'}; } $sth->finish(); $sql = "SELECT TRX_GROUP_ID, SUM(TRX_FREQ) AS TRX_FREQ, SUM(TRX_AMOUNT) AS TRX_AMOUNT, TRX_CURRENCY FROM FX_BIN_TRX_RPT "; $sql .= "WHERE DATE BETWEEN '" . "$sMonth/$sDay/$sYear" . "' AND '" . "$eMonth/$eDay/$eYear" . "' "; $sql .= "GROUP BY TRX_GROUP_ID, TRX_CURRENCY "; $sql .= "ORDER BY TRX_GROUP_ID"; $sth = KAB_Util->ExecQuery($dbh, $sql); while ($row = $sth->fetchrow_hashref()) { $trxGroupID = $row->{'TRX_GROUP_ID'}; $trxGroups[$trxGroupID]{'SUMM_FREQ'}{ $row->{'TRX_CURRENCY'} } = $row->{'TRX_FREQ'} || ''; $trxGroups[$trxGroupID]{'SUMM_AMOUNT'}{ $row->{'TRX_CURRENCY'} } = $row->{'TRX_AMOUNT'} || ''; } $sth->finish(); i use DB2 for this application. i just want to get the reference name from second array, anyway to do it? FYI : i've tried print $trxGroups[$trxGroupID]{'SUMM_AMOUNT'}; and it failed so please help me Be free to decide your dream, Put the details of your dream in your head and heart And don't give up 'till you drop dead.
|