小弟用perl連結oracle後 欲將sql資料輸出在網頁上
一般使用都沒有問題
但在SQL敘述內如果有使用到
table相除=> a欄/b欄 as Data 或是
case(xxx) as Data 等功能
print $Data{'Data'}的功能就失效了
而且只有這一欄顯示不出來 其他都可以
難道資料名稱不是叫Data嗎? 如何讓他可以print出來??
完整程式碼附上
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();