[問題]PERL連資料庫後的資料矩陣

看板Perl作者 (= =)時間12年前 (2013/03/03 18:09), 編輯推噓0(001)
留言1則, 1人參與, 最新討論串1/1
小弟最近剛接觸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(); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 180.177.13.161

04/20 16:25, , 1F
自問自答 push @A, $Data{'ID'}; 再去整理@A的資料
04/20 16:25, 1F
文章代碼(AID): #1HCo5dJI (Perl)
文章代碼(AID): #1HCo5dJI (Perl)