我的代码正在运行,该函数为我提供了正确的选择计数 (*) 值,但无论如何,它都会引发 ORA-25191 异常 - 无法引用索引组织表提示的溢出表,位于 retVal = Convert.ToInt32(cmd.ExecuteScalar ());
由于我经常使用该函数,异常会极大地减慢我的程序。
private int getSelectCountQueryOracle(string Sqlquery)
{
try
{
int retVal = 0;
using (DataTable dataCount = new DataTable())
{
using (OracleCommand cmd = new OracleCommand(Sqlquery))
{
cmd.CommandType = CommandType.Text;
cmd.Connection = oraCon;
using (OracleDataAdapter dataAdapter = new OracleDataAdapter())
{
retVal = Convert.ToInt32(cmd.ExecuteScalar());
}
}
}
return retVal;
}
catch (Exception ex)
{
exceptionProtocol("Count Function", ex.ToString());
return 1;
}
}
该函数在foreach
循环中调用
// function call in foreach loop which goes through tablenames
foreach (DataRow row in dataTbl.Rows)
{...
tableNameFromRow = row["TABLE_NAME"].ToString();
tableRows=getSelectCountQueryOracle("select count(*) as 'count' from " +tableNameFromRow);
tableColumns = getSelectCountQueryOracle("SELECT COUNT(*) as 'count' FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name='" + tableNameFromRow + "'");
...}
dataTbl.rows
在这个外部循环中,反过来,来自查询
SELECT * FROM USER_TABLES ORDER BY TABLE_NAME