[请益] 连oracle但某些字段print出不来

楼主: SuLaPKLa (= =)   2013-02-20 19:42:36
小弟用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();
作者: CindyLinz (Cindy Wang)   2013-02-22 12:19:00
试试看把 as Data 改成 as "Data"
楼主: SuLaPKLa (= =)   2013-02-23 23:01:00
阿居然是PERL不支援中文 XD 谢谢楼上这位大大
作者: flu (Crazy Rhythm)   2013-02-24 03:49:00
Perl当然支援中文啊,连问它何谓"生 & 死"都可以用中文回答

Links booklink

Contact Us: admin [ a t ] ucptt.com