高分提问回答即得分:VC中如何使用oracle过程中游标返回结果集到界面修改后,再通过ADO进行updatebatch?错误提示:Insufficient base table
多个论坛上都没有人能够回答,请教此处高手:
首先是在C++中:对于数据库的连接:
hr=m_pConnection.CreateInstance(__uuidof(Connection));
hr=m_pConnection->Open(m_vUserDsn.bstrVal,m_vUserName.bstrVal,m_vUserPass.bstrVal,adConnectUnspecified);
m_pConnection->CursorLocation=adUseClient;
m_pConnection->CommandTimeout = 0;
m_pCommand.CreateInstance(__uuidof(Command));
m_pCommand->putref_ActiveConnection(m_pConnection);
m_pCommand->put_CommandType(adCmdStoredProc);
spRecordset->PutCursorLocation(adUseClientBatch);
spRecordset->put_CursorType(adOpenStatic);
spRecordset->put_LockType(adLockBatchOptimistic);
spRecordset->PutRefActiveConnection(m_pConnection);
spRecordset->Open(vSQL,
_variant_t(DISP_E_PARAMNOTFOUND, VT_ERROR),
adOpenStatic,
adLockBatchOptimistic,
adCmdStoredProc);
在调用存储过程取结果集时如下:
/* if (nIndex == 1)
strSQL.Format(_T(" select * FROM VMI_DeliveryBillHead where DeliveryNo = '%s' " ), CString(bstrBillId));
else*/
strSQL.Format(_T(" { Call IN_Customs_DeliveryBillInfoGet.IN_Customs_DeliveryBillInfoGet (%d,'%s','%s','%s','%s') } "),
nIndex,CString(bstrBillId),CString(bstrParam),CString(bstrParam1),CString(bstrParam2));
if(ExecSQL(CComVariant(strSQL), pResults)==S_FALSE) return S_FALSE;
进行updatebatch时的代码:
pRecordset->PutRefActiveConnection(m_pConnection);
pRecordset->UpdateBatch(adAffectAll);
pRecordset->PutRefActiveConnection(NULL);
调用结果集时如果使用nindex=1,即使用sql语句取数据,完全可以updatebatch,但是使用存储过程中的游标取,就不行,出现基础表信息不足的错误提示:Insufficient base table information for updating or refreshing.
存储过程如下:
create or replace package body IN_PORD_WORKTIMEPACK is
procedure IN_ProduceTimeExtend(returncur out basic_cursor) is
begin
open returncur for
SELECT ID, WorkshopName, WorkshopId , TimeExtend ,
Recorder , RecordTime
FROM Prod_WorkTimeExtend ;
end;
end IN_PORD_WORKTIMEPACK;
请问能用存储过程进行updatebatch?还是别有原因?如何解决,多谢!
问题点数:0、回复次数:4Top
1 楼cdwy411(VC$ORACLE)回复于 2003-11-02 11:10:37 得分 0
ADO只能对键集或静态游标使用批更新。
存储过程中输出的是动态游标。
Top
2 楼crystalcat(crystal)回复于 2003-11-02 11:18:06 得分 0
那么这种问题该怎么解决?也就是我希望通过ADO的Updatebatch实现对存储过程中的游标进行批更新,而不是使用commandtext来写一条sql语句?Top
3 楼crystalcat(crystal)回复于 2003-11-02 11:53:58 得分 0
现在不能结贴,给不了分数,请大侠帮忙,问题一解决马上结贴!
我在index=1时的注释打开,就可以,但是使用存储过程就不行,再说recordset已经打开前被设为了静态游标了!Top
4 楼crystalcat(crystal)回复于 2003-11-04 11:19:52 得分 0
另外,我变通了一下,想要对于
FieldPtr pField2 = updRecordset->GetFields()->GetItem(CComVariant(i));
做以下操作修改:
pField2->GetProperties()->GetItem(CComVariant(j))->PutValue(val1);
或者
pField2->GetProperties()->GetItem(CComVariant(j))->PutAttributes(adPropWrite);
对结果集中的属性进行修改,
结果出现Operation is not allowed in this context.的错误,请问是什么原因?Top




