Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
# Start first sql... my $dbh = DBI->connect... my $sql = " SELECT acc_num, date, user1, user2, user3, user4, user5, user6, user7, FROM users_info WHERE date='2009-04-11' "; my $sth = $dbh->prepare($sql)|| die $dbh->errstr; $sth->execute() or die "$!\n"; my $array_ref = $sth->fetchall_arrayref(); my @ar_acc_num; foreach my $vals (@$array_ref){ my ($acc_num, $date, $all_users) =@$vals; push @ar_acc_num ,$pol_num; # I will need to push $date into an array as well, but one problem at +a time. } # here I have part of the data I need unshift @{ $array_ref }; # here I have all the acc numbers I need to go after on the second tab +le: # print "@ar_acc_num"; # Start second sql... my $dbh_b = DBI->connect... my $values = join("," ,map { $dbh_sec->quote($_) } @ar_acc_num ); my $sql_b = " SELECT add, acc, date, email, phone, city, state, country, reg FROM all_info WHERE date='2009' /* # it should be the value of $date pu +shed previously but for now I am using static year of 2009 */ AND acc IN ($values) "; my $sth_b = $dbh_b->prepare($sql_b)|| die $dbh_b->errstr; $sth_b->execute() or die "$!\n"; my $header = [ "Acc. Num", "Date", "User 1", "User 2", "User 3", "User 4", "User 5", "User 6", "User 7", "Add", "Acc", "Email", "Phone", "City", "State", "Country", "Regular", ]; my $array_ref_b = $sth_b->fetchall_arrayref(); #***Here I need to add @{ $array_ref } to @{ $array_ref_b } to contai +n all the data I need to format my report, that's where my problem is, how to do that? ## @{ $array_ref_b }= @{ $array_ref }.@{ $array_ref_b }; unshift @{ $array_ref_b }, $header;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Array_ref into Array_ref Help.
by kennethk (Abbot) on Apr 22, 2009 at 15:45 UTC | |
|
Re: Array_ref into Array_ref Help.
by toolic (Bishop) on Apr 22, 2009 at 15:47 UTC | |
|
Re: Array_ref into Array_ref Help.
by lostjimmy (Chaplain) on Apr 22, 2009 at 15:49 UTC | |
by Anonymous Monk on Apr 22, 2009 at 17:16 UTC | |
by lostjimmy (Chaplain) on Apr 22, 2009 at 17:32 UTC | |
by Anonymous Monk on Apr 22, 2009 at 17:42 UTC | |
by kennethk (Abbot) on Apr 22, 2009 at 17:49 UTC | |
by lostjimmy (Chaplain) on Apr 22, 2009 at 17:56 UTC | |
by Anonymous Monk on Apr 22, 2009 at 18:08 UTC | |
by lostjimmy (Chaplain) on Apr 22, 2009 at 19:32 UTC | |
| |
|
Re: Array_ref into Array_ref Help.
by Bloodnok (Vicar) on Apr 22, 2009 at 16:37 UTC |