我们在使用 Oracle Odp.Net(连接到 Oracle 9)时遇到了一个奇怪的错误。下面的代码片段说明了这个问题。
这是我们遇到的错误:
ORA-00600: 内部错误代码, 参数: [15419], [PL/SQL 执行期间出现严重错误], [], [], [], [], [], []
ORA-06544: PL/SQL: 内部错误, 参数: [78502], [], [], [], [], [], [], []
ORA-06553: PLS-801: 内部错误 [78502]
谷歌搜索让我们怀疑(尽管我们不完全确定)Odp.Net 不支持传递时间戳数组。
所以问题是2倍的:
- 是否可以使用 odp.net 将时间戳数组传递给 pl/sql 过程?
- 如果没有,是否有一个好的解决方法?
说明问题的 C# 控制台程序:
using System;
using System.Collections;
using System.Data;
using Oracle.DataAccess.Client;
class Program
{
private const string _db = "<db>";
private const string _username = "<user>";
private const string _password = "<password>";
private const string _storedProcedureName = "<sproc>";
static void Main(string[] args)
{
var connectionString = string.Format(
"data source={0};user id={1};password={2}",
_db, _username, _password);
var connection = new OracleConnection(connectionString);
try
{
connection.Open();
var timeStamps = new[] { DateTime.Now, DateTime.Now };
var parameter = new OracleParameter("inTimeStamps", OracleDbType.TimeStamp)
{
Direction = ParameterDirection.Input,
CollectionType = OracleCollectionType.PLSQLAssociativeArray,
Size = timeStamps.Length,
Value = timeStamps
};
var command = connection.CreateCommand();
command.CommandType = CommandType.StoredProcedure;
command.CommandText = _storedProcedureName;
command.Parameters.Add(parameter);
command.ExecuteReader();
}
finally
{
connection.Close();
}
}
}
该代码正在调用以下 PL/SQL 存储过程
TYPE ArrayOfTimestamps is table of timestamp index by binary_integer;
PROCEDURE TestOdpTimeStamp (inTimeStamps in ArrayOfTimestamps)
IS
test number;
BEGIN
select 1 into test from dual;
END;