0
我正在連接cakephp上的sql server 2008 r2。我需要拉Excel進行我所創建的存儲過程如下Cakephp/mssql中的遊標狀態無效
ALTER procedure [dbo].[pullatm_card]
@date varchar(25)
as
begin
declare @sql as varchar(1000)
set @sql='INSERT INTO scts
(
terminal,
account_number,
txn_amount,
txn_date,
txn_tim,
trace_code
)
select
f2 as terminal,
f6 as account_number,
f10 as txn_amount,
f14 as txn_date,
f22 as txn_time,
f27 as trace_code
FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',
''Excel 8.0;Database=C:\rbl\sct\'[email protected]+'\excel\atm\cards.xls;IMEX=1'',
''SELECT * FROM [Sheet1$]'')
where f14 is not null'
exec(@sql)
當我火
exec pullatm_card'DEC01_2013EXCEL' on sql server query editor it is running sucessfully.
但是當我嘗試同樣的CakePHP中,如下
public function admin_add() {
if ($this->request->is('post')) {
//call three procedure here
$date=$this->request->data['Sct']['date'];
$this->Sct->query("exec pullatm_card"."'".$date."'");
$this->Sct->query("exec pullatm_loro"."'".$date."'");
$this->Session->setFlash(__('SCT record(s) been saved'));
$this->redirect(array('action' => 'add'));
}
}
它會拋出如下錯誤:
Database Error
Error: SQLSTATE[24000]: [Microsoft][SQL Server Native Client 10.0]Invalid cursor state
SQL Query: exec pullatm_card'DEC01_2013EXCEL'
但是,將exec pullatm_card'DEC01_2013EXCEL'的結果插入到數據庫中,並且在此之後暫停所有其他操作,即查詢就在它下面(請參閱php)不會被解僱?
可能是什麼問題?