PERL与Win32:ODBC / DBI读取很多表,然后一个没有返回任何表

时间:2012-10-16 21:10:47

标签: sql-server perl odbc

##Read table staStations
if ($mssqldb->Sql("SELECT stationID, security, dockingCostPerVolume, maxShipVolumeDockable, officeRentalCost, operationID, stationTypeID, corporationID, solarSystemID, constellationID, regionID, stationName, reprocessingEfficiency, reprocessingStationsTake, reprocessingHangarFlag
 FROM staStations")) {
    print "SQL Error: " . $mssqldb->Error() . "\n";
    $mssqldb->disconnect;
    exit;
}


# Read table staStations
$count = 0 ;

while ($mssqldb->FetchRow) {
    my ($stationID, $security, $dockingCostPerVolume, $maxShipVolumeDockable, $officeRentalCost, $operationID, $stationTypeID, $corporationID, $solarSystemID, $constellationID, $regionID, $stationName, $reprocessingEfficiency, $reprocessingStationsTake, $reprocessingHangarFlag) = $mssqldb->Data();  ### Get data values from the row
    $stationName =~ s/\'/\'/g;
    $mysqlconnect->do("INSERT INTO staStations(stationID, security, dockingCostPerVolume, maxShipVolumeDockable, officeRentalCost, operationID, stationTypeID, corporationID, solarSystemID, constellationID, regionID, stationName, reprocessingEfficiency, reprocessingStationsTake, reprocessingHangarFlag)
    VALUES ('$stationID', '$security', '$dockingCostPerVolume', '$maxShipVolumeDockable', '$officeRentalCost', '$operationID', '$stationTypeID', '$corporationID', '$solarSystemID', '$constellationID', '$regionID', '$stationName', '$reprocessingEfficiency', '$reprocessingStationsTake', '$reprocessingHangarFlag') ;");
    $count = $count + 1 ;
    print $count . " Rows into staStations \n" ;

}

第一部分工作正常

    if ($mssqldb->Sql("SELECT iconID, iconFile, description FROM eveIcons")) {
    print "SQL Error: " . $mssqldb->Error() . "\n";
    $mssqldb->disconnect;
    exit;
}



# write table eveIcons
foreach ($mssqldb->FetchRow()) {
    my ($iconID, $iconFile, $description) = $mssqldb->Data();  ### Get data values from the row
    $description =~ s/\'/\'/g;
    #$iconFile  =~ s/\_/\_/g;
    print "iconID: " . $iconID . "\n" ;
    print "file: " . $iconFile . "\n" ;
    print "desc: " . $description . "\n \n" ;
    $mysqlconnect->do("INSERT INTO eveIcons(`iconID`, `iconFile`, `description`)
    VALUES ('$iconID', '$iconFile', '$description') ;");
    $count = $count + 1 ;
    print $count . " Rows into eveIcons \n" ;
}

无法找到问题,但不会返回任何内容 这没有数据..

它放置了一个" 0"在我的MySql表的第一列

MSSQL表中有1689条记录,我在做什么?

2 个答案:

答案 0 :(得分:1)

我从mssql和LongTruncOk读取长数据列时遇到了麻烦,LongReadLen解决了这些问题。

看起来你在编写它们时遇到了麻烦。试着看一下这个技巧:http://publib.boulder.ibm.com/infocenter/db2luw/v9/index.jsp?topic=%2Fcom.ibm.db2.udb.apdv.sample.doc%2Fdoc%2Fperl%2Fs-dtlob-pl.htm

有一些如何编写blob的示例。尝试将其应用于您的说明字段。

答案 1 :(得分:0)

我不太明白为什么,但关于MSSQL服务器上的描述字段 我试图分配大量的内存,一旦我试图复制该列,它工作正常,

更多信息 MSSQL表上的数据类型设置为VARCHAR(MAX), 虽然该列中的所有字段都没有超过127个字符