我现在想实现一个判断ORACLE中一个视图是否存在,如果存在就删除。在程序中我这样写的:(dbcontroler是一个封装了ADO操作的类的对象)try
{
#pragma region [删掉老的视图]
csSqlText.Format("SELECT COUNT(*) AS 视图计数 FROM SYS.ALL_VIEWS WHERE VIEW_NAME='%s';",csViewName);
if (!dbcontroler.Connect_to((_bstr_t)m_csOracleConnectionText)) return;
if (!dbcontroler.OpenRecordSet(csSqlText)) return;
if ( dbcontroler.p_RecordSet->ADOEOF) return;
dbcontroler.p_RecordSet->MoveFirst();
iViewCounter = dbcontroler.p_RecordSet->GetCollect("视图计数");
if (iViewCounter > 0)
{
csSqlText.Format("DROP VIEW %s",csViewName);
dbcontroler.UpDataDB(csSqlText);
}
dbcontroler.p_RecordSet->Close();
dbcontroler.p_Connection->Close(); }
catch(_com_error e)
{
CString errorString;
errorString.Format(_T("数据库异常 ,异常信息:%s"),e.ErrorMessage());
AfxMessageBox(errorString);
return ;
}总是提示视图不存在。但是,我直接在oracle中执行"SELECT COUNT(*) AS 视图计数 FROM SYS.ALL_VIEWS WHERE VIEW_NAME='去年产量'";是可以的。这时为什么?如何才能在程序里面实现视图的删除呢?
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/leoandjill/archive/2009/11/30/4909240.aspx
{
#pragma region [删掉老的视图]
csSqlText.Format("SELECT COUNT(*) AS 视图计数 FROM SYS.ALL_VIEWS WHERE VIEW_NAME='%s';",csViewName);
if (!dbcontroler.Connect_to((_bstr_t)m_csOracleConnectionText)) return;
if (!dbcontroler.OpenRecordSet(csSqlText)) return;
if ( dbcontroler.p_RecordSet->ADOEOF) return;
dbcontroler.p_RecordSet->MoveFirst();
iViewCounter = dbcontroler.p_RecordSet->GetCollect("视图计数");
if (iViewCounter > 0)
{
csSqlText.Format("DROP VIEW %s",csViewName);
dbcontroler.UpDataDB(csSqlText);
}
dbcontroler.p_RecordSet->Close();
dbcontroler.p_Connection->Close(); }
catch(_com_error e)
{
CString errorString;
errorString.Format(_T("数据库异常 ,异常信息:%s"),e.ErrorMessage());
AfxMessageBox(errorString);
return ;
}总是提示视图不存在。但是,我直接在oracle中执行"SELECT COUNT(*) AS 视图计数 FROM SYS.ALL_VIEWS WHERE VIEW_NAME='去年产量'";是可以的。这时为什么?如何才能在程序里面实现视图的删除呢?
本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/leoandjill/archive/2009/11/30/4909240.aspx
解决方案 »
- MFC单文档中帮助菜单中的帮助单击后弹出对话框怎么做的?
- 我把定时器放入辅助线程里面,结果定时器的回调函数不起作用?是微软故意这样做的呢?
- float值,如果太大的话,会表示成1e+006的形式,怎么设置它成通常的形式呢?
- 老大们 请问如何把纯文本表格中的内容保存为word格式文件(我只有二十分了)
- 如何让鼠标变成沙漏状,先谢了
- 在VC中定义unsigned long* Input,在DELPHI该如何定义阿!急!
- 请教一个关于CComboBox控件类型由dropdown改变为dropdownlist的问题!谢谢!急!
- 逻辑坐标系的原点(0,0)在设备坐标的那个位置?
- CListBox
- vs2010中使用ActiveX 控件,Label能加入,不能显示,如何解决?
- evc中的蓝牙问题
- (求教)如何编写类似支付宝密码输入框的activex控件!
这里csViewName是否正确值。
Format中,'%s'后的分号是否可以不写