我的存储过程调用确实返回 7 行,但不是当我通过 Oracle 托管数据访问调用它时。
代码 :
string _connectionString =
String.Format("Data Source={0};User Id={1};Password={2};",
tbDataSource.Text, tbUser.Text, tbPassword.Text);
using (OracleConnection conn = new OracleConnection(_connectionString)){
using (OracleCommand cmd = new OracleCommand()){
cmd.CommandText = "XXCOOT_QUERIES.getWarehouses";
cmd.CommandType = CommandType.StoredProcedure;
// Parameters
OracleParameter p1 = new OracleParameter();
p1.ParameterName = "inumActivityId";
p1.OracleDbType = OracleDbType.Varchar2;
p1.Direction = ParameterDirection.Input;
p1.Size = 10;
p1.Value = 108;
cmd.Parameters.Add(p1);
OracleParameter cursor = new OracleParameter();
cursor.ParameterName = "ocursWarehouses";
cursor.OracleDbType = OracleDbType.RefCursor;
cursor.Direction = ParameterDirection.Output;
cmd.Parameters.Add(cursor);
OracleParameter p2 = new OracleParameter();
p2.ParameterName = "ostrErrCode";
p2.OracleDbType = OracleDbType.Varchar2;
p2.Direction = ParameterDirection.Output;
p2.Size = 2000;
cmd.Parameters.Add(p2);
DataTable dt = new DataTable();
OracleDataReader reader = null;
conn.Open();
cmd.Connection = conn;
using (reader = cmd.ExecuteReader()){
dt.Load(reader);
this.tbResult.Text = "Rows Count : " +
dt.Rows.Count.ToString(); // Returns: "Rows Count : 0"
this.dataGridView1.DataSource = dt.DefaultView;
// Returns : " | Column1 | Column2 | "
// |-------- | --------|
}
}
}
存储过程
PROCEDURE getWarehouses
( inumActivityId in varchar2
, ocursWarehouses out grefCursorType
, ostrErrCode out varchar2
)
IS
lextorg varchar2(150);
BEGIN
FND_CLIENT_INFO.Set_Org_Context(inumActivityId);
lextorg := null;
SELECT b.GENERIC_EXTERNAL_ORGANIZATION
INTO lextorg
FROM HR_ORGANIZATION_INFORMATION a
, HR_ORGANIZATION_INFORMATIO_DFV b
WHERE a.organization_id = to_number(inumActivityId)
AND a.ORG_INFORMATION_CONTEXT = 'Operating Unit Information'
AND a.rowid = b.rowid;
IF lextorg is null THEN
OPEN ocursWarehouses FOR
SELECT ood.organization_code organization_code
, ood.organization_name name
FROM org_organization_definitions ood
, mtl_parameters mp
, mtl_parameters_dfv mp_dfv
WHERE ood.operating_unit = to_number(inumActivityId)
AND sysdate <= nvl(disable_date,sysdate)
AND ood.organization_id = mp.organization_id
AND mp.rowid = mp_dfv.row_id
AND upper(mp_dfv.warehouse_type) in ('INTERNAL','EXTERNAL')
ORDER by organization_name;
ELSE
OPEN ocursWarehouses FOR
SELECT ood.organization_code organization_code
, ood.organization_name name
FROM org_organization_definitions ood
, mtl_parameters mp
, mtl_parameters_dfv mp_dfv
WHERE -ood.operating_unit = to_number(inumActivityId)
AND sysdate <= nvl(disable_date,sysdate)
AND ood.organization_id = mp.organization_id
AND mp.rowid = mp_dfv.row_id
AND upper(mp_dfv.warehouse_type) in ('INTERNAL','EXTERNAL')
ORDER by organization_name;
END/
执行时: 无警告,无错误(所有参数均有效)
我的问题: 返回任何行(而不是预期的 7 行),但我检索了架构(列名是正确的)。
环境 :
- 视窗 x64
- .NET 框架:4.0
- 已安装 Oracle 客户端 (v11.2) 但不是必需的
- Oracle 数据提供者 .NET:Oracle.ManagedDataAccess (v121.1.2)