[问题]PERL连数据库后的资料矩阵

楼主: SuLaPKLa (= =)   2013-03-03 18:09:40
小弟最近刚接触PERL
所以sorry 又来问笨问题了
目前的程式 只连一个数据库 可以把它完整秀出在网页上
但现在想在一个网页 连两个数据库
并把两个数据库抓下来的资料做一个整合
因此....
问题一
连完数据库的完整矩阵叫什么名字啊
是%Data吗???
问题二
如果我连两个数据库 抓到Data1 & Data2
有没有像excel那种vlookup的功能
能够用关键字段 自动将两个矩阵结合的语法呢???
比如说
Data1 产品 价格 Data2 产品 数量
A 10 A 2
B 20 B 5
变成
Data3 产品 价格 数量
A 10 2
B 20 5
附上程式码如下 目前只连一个数据库
use Win32::ODBC;
# set Data Source Name
$DSN = "Samples";
# Open connection to DSN
if (!($O = new Win32::ODBC($DSN))){
print "Failure. \n\n";
exit();
}
# set Table name
$Table = Product;
# Get the content of the table.
if (! $O->Sql("SELECT * FROM $Table"))
{
# print out the field names.
@FieldNames = $O->FieldNames();
$Cols = $#FieldNames + 1;
for ($iTemp = 0; $iTemp < $Cols; $iTemp++){
$FmH2 .= "$FieldNames[$iTemp] ";
}
chop $FmH2;
print "$FmH2\n";
# Fetch the next rowset
while($O->FetchRow()){
undef %Data;
%Data = $O->DataHash();
print $Data{'ID'}, " ", $Data{'Name'}, " ",
$Data{'Price'}, " ", $Data{'Qty'}, "\n";
}
}
# Close Connection.
$O->Close();
楼主: SuLaPKLa (= =)   2013-04-20 16:25:00
自问自答 push @A, $Data{'ID'}; 再去整理@A的资料

Links booklink

Contact Us: admin [ a t ] ucptt.com