我正在尝试遍历光标。当我直接在 pl/sql 中执行命令(表示为 sql - 见下文)时,我得到的结果集包含更多行。但是当我运行这段代码时,我只得到一行:
using (OracleConnection conn = new OracleConnection(connstring))
{
conn.Open();
string sql = "select close, ts from dpr@price where qot_id=2029543939 and ts>='" + start + "' and ts<='" + end + "'";
using (OracleCommand comm = new OracleCommand(sql, conn))
{
using (OracleDataReader rdr = comm.ExecuteReader())
{
while (rdr.Read())
{
Console.WriteLine(rdr.GetOracleDecimal(0));
}
}
}
}
代码不会抛出任何异常(至少不是以通常的方式;我的意思是它不会停止或写入堆栈跟踪)。但是,我可以在调试时通过 reader Object 看到这些行(我认为这与这里无关,但显示输出“以防万一”):
InitialLONGFetchSize = 'rdr.InitialLONGFetchSize' threw an exception of type 'System.NullReferenceException'
InitialLOBFetchSize = 'rdr.InitialLOBFetchSize' threw an exception of type 'System.NullReferenceException'
结果应该只有类型DateTime
和Number (10,4)
。并且该表没有类型为 lob 或 long 的字段。
这是表格方案:
QOT_ID NUMBER
TS DATE
CLOSE NUMBER
OPEN NUMBER
HIGH NUMBER
LOW NUMBER
KASSE NUMBER
VOLUME NUMBER
CLOSE_BID NUMBER
SPL_BEREINIGT VARCHAR2
OPEN_INTEREST NUMBER
TRADES NUMBER
TURNOVER NUMBER
HIGH_BID NUMBER
LOW_ASK NUMBER
The query is correct and the entries exist. The returned row seems to be random one... It is not the first or last row. I'm using ODT with ODAC 11. I have VS2012 and working under windows 7(32-bit). I'm connected to Oracle 10g .
Any clue what am I doing wrong?