asp.netを使用してOracleデータベースからデータを取得しようとしていますが、データがテーブルに存在する間、カーソルに出力がありません:次のストアドプロシージャを使用しています:
CREATE OR REPLACE PROCEDURE branch_details
( startIndex in int
,pageSize in int
,isSearch in int
,byName in int
,dataDetail in varchar2
, p_cursor out sys_refcursor)
AS
BEGIN
IF isSearch=1 THEN
IF byName=1 THEN
OPEN p_cursor FOR
SELECT *
FROM (SELECT ROW_NUMBER() OVER(ORDER BY branch_id)
AS MyRows
, branch_id, branch_name
, branch_location, bm_name, bm_contact
, bm_email, is_active, max_ua
, (SELECT COUNT(branch_id)
FROM branch_info
WHERE branch_name LIKE
'%'|| dataDetail||'%')
AS RowNumber
FROM branch_info
WHERE branch_name LIKE '%'|| dataDetail||'%')
WHERE MyRows BETWEEN startIndex
AND startIndex+pageSize-1;
ELSE
OPEN p_cursor FOR
SELECT *
FROM (SELECT ROW_NUMBER() OVER(ORDER BY branch_id)
AS MyRows
, branch_id, branch_name, branch_location
, bm_name, bm_contact, bm_email, is_active
, max_ua
, (SELECT COUNT(branch_id)
FROM branch_info
WHERE branch_id LIKE
'%'|| dataDetail||'%')
As RowNumber
FROM branch_info
WHERE branch_id LIKE '%'|| dataDetail||'%')
WHERE MyRows BETWEEN startIndex
AND startIndex+pageSize-1;
END IF;
ELSE
OPEN p_cursor FOR
SELECT *
FROM (SELECT ROW_NUMBER() OVER(ORDER BY branch_id)
AS MyRows
, branch_id, branch_name, branch_location
, bm_name, bm_contact, bm_email
, is_active, max_ua
, (SELECT COUNT(branch_id)
FROM branch_info) AS RowNumber
FROM branch_info)
WHERE MyRows BETWEEN startIndex
AND startIndex+pageSize-1;
END IF;
END;
そして、次のasp.netコードを使用します:
List<Paramarray> param = new List<Paramarray>();
param.Add(new Paramarray("@dataDetail", data));
param.Add(new Paramarray("@byName", id?"0":"1"));
param.Add(new Paramarray("@isSearch", isSearch?"1":"0"));
param.Add(new Paramarray("@startIndex", startIndex==1?startIndex.ToString():Convert.ToString(((startIndex-1)*pageSize)+1)));
param.Add(new Paramarray("@pageSize", pageSize.ToString()));
_command.Connection = _connection;
_command.CommandType = CommandType.StoredProcedure;
_command.CommandText = "branch_details";
foreach (Paramarray _param in param)
{
_parameter = new OracleParameter(_param.name,_param.value);
_command.Parameters.Add(_parameter);
}
_command.Parameters.Add("@p_cursor", OracleDbType.RefCursor).Direction = ParameterDirection.Output;
if (_connection.State != ConnectionState.Open) _connection.Open();
_dataReader = _command.ExecuteReader();
dt.Load(_dataReader);
if (_connection.State == ConnectionState.Open) _connection.Close();
別の手順の同じコードが正常に機能し、出力が得られます。
手順や他の場所で間違っている場合は、助けてください。私は問題を理解することができません。