ストアド プロシージャの呼び出しでは 7 行が返されますが、Oracle Managed Data Access を介して呼び出した場合は返されません。
コード :
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行ではなく)任意の行が返されますが、スキーマを取得します(列名は正しいです)。
環境 :
- Windows x64
- .NET フレームワーク: 4.0
- Oracle クライアントがインストールされている (v11.2) が必要ではない
- Oracle データ プロバイダー .NET : Oracle.ManagedDataAccess (v121.1.2)