我将旧的 Access.mdb 移植到新的 MSSQL 数据库中,并进行了微小的更改。我有一个简单的循环:
//$_new is an MSSQL2011-ODBC-Datasource
//$_old is an old MSACCESS.mdb-ODBC-Datasource
$devices_result = odbc_exec($_old,"SELECT * FROM Druckerarchiv");
$device_insert_prepare = odbc_prepare($_new,"INSERT INTO Geraetearchiv (Kd_Nr,
[Typ],Seriennummer,Firma,Rg_Datum,Dauer,Markerart,Zus_Papierfach,Duplexeinheit,
Universalzufuhr,Plz,Ort,Strasse,Bemerkungen,Telefon,Fax,Ansprechpartner,Abteilung,
Wartung_BEGINN,Wartung_ENDE,Reaktions_TIME,Fix_TIME,Autom_Verl,Vertrags_Nr,
W_EK,W_VK,Wartung_LAUFZEIT,Absprachen,Drucker_USB,Drucker_LAN,Drucker_Parallel,
Drucker_Printserver,Drucker_Printserver_Typ,Drucker_Printserver_Sn,
Drucker_Zusatz,Email,Dienstleister,Garantieverlaengerung,
GVServicedienstleister,Aktiv,Typnummer,Firma_Standort) VALUES
(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,
?,?,?,?,?,?,?,?,?,?,?,?,?)");
while($device = odbc_fetch_array($devices_result))
{
$device_insert = array(
utf8_encode($device['KD_NR']),
utf8_encode($device['Druckertyp']),
utf8_encode($device['Seriennummer']),
utf8_encode($device['Firma']),
$device['Rg-Datum'],
(float)$device['Dauer'],
(float)$device['Markerart'],
(int)$device['2_Papierfach'],
(int)$device['Duplexeinheit'],
(int)$device['Universalzufuhr'],
utf8_encode($device['Plz']),
utf8_encode($device['Ort']),
utf8_encode($device['Straße']),
utf8_encode($device['Bemerkungen']),
utf8_encode($device['Telefon']),
utf8_encode($device['Fax']),
utf8_encode($device['Ansprechpartner']),
utf8_encode($device['Abteilung']),
$device['Wartung_BEGINN'],
$device['Wartung_ENDE'],
(int)$device['Reaktions_TIME'],
(int)$device['Fix_TIME'],
(int)$device['Autom_Verl'],
utf8_encode($device['VERTRAGS_NR']),
(double)$device['W-EK'],
(double)$device['W-VK'],
(float)$device['Wartung_LAUFZEIT'],
utf8_encode($device['Absprachen']),
0,
(int)$device['Ethernet'],
0,
0,
'',
'',
(($device['Y-Adapter/Typ'])?
("Hat Y-Adapter ".$device['Y-Adapter/Typ']." SN: ".$device['Y-Adapter/SN']):null),
'',
(int)$servicedienstleister[$markerart[
(int)$device['Markerart']]], //dienstleister
'',
'',
1,
'',
'',
);
odbc_execute($device_insert_prepare,$device_insert);
}
此循环运行前 2 到 3 次。但在那之后,它每次运行都失败并抛出
Warning: odbc_execute() [function.odbc-execute]: SQL error:
[Microsoft][SQL Server Native Client 11.0]Function sequence error,
SQL state S1010 in SQLDescribeParameter
由于这个循环应该做大约 30k 轮,我想将它作为准备好的语句运行并执行大约 30k 次。我已经尝试关闭自动提交。我错过了什么?