【问题标题】:Invalid cursor state in Cakephp/mssqlCakephp/mssql 中的游标状态无效
【发布时间】:2013-12-10 12:00:59
【问题描述】:

我在 cakephp 上连接 sql server 2008 r2。我需要拉出我为其创建了存储过程的excel,如下所示

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\'+@date+'\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)不会被触发?

可能是什么问题?

【问题讨论】:

    标签: php sql sql-server cakephp


    【解决方案1】:

    继续下面的链接,这可能会对您有所帮助。

    http://bakery.cakephp.org/articles/icc97/2011/09/25/sql_server_storedprocedure_behaviour

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-10-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-04-13
      • 1970-01-01
      相关资源
      最近更新 更多