Question: Can I use OUT:
Both: variable and cursor A, from my code below <
I saw a similar question for SqlDB, but after a very long search, no solution was found for OracleDB.
In PLSQL:
CREATE OR REPLACE
PROCEDURE SPGETRESULTANDSETFLAG
(
pFilter VARCHAR2,
pMaxRowCount VARCHAR2,
pTableID RAW,
myFlag OUT NUMBER,
myCursor OUT types.cursorType
)
AS
BEGIN
Declare
CountQuery VARCHAR(20000) := '';
DataQuery VARCHAR(20000) := '';
ResultingRows NUMBER := -1;
Begin
myFlag := -1;
CountQuery := 'SELECT COUNT(*) FROM '
|| F_GET_TABLENAME_FROM_ID(PTABLEID => pTableID)
|| ' WHERE ' || pFilter;
EXECUTE IMMEDIATE CountQuery INTO ResultingRows;
--Get the Return Value
if( pMaxRowCount > ResultingRows ) then myFlag := 1; end if;
DataQuery := 'SELECT * FROM '
|| F_GET_TABLENAME_FROM_ID(PTABLEID => pTableID)
|| ' WHERE ' || pFilter;
--Get the Return Cursor
Open myCursor for DataQuery;
End;
END SPGETRESULTANDSETFLAG;
In the code below ..
Database db = DBSingleton.GetInstance();
using (DbCommand command = db.GetStoredProcCommand(spName))
{
//The three Add In Parameters... & then the Add out Parameter as below
db.AddOutParameter(command, "myFlag", System.Data.DbType.Int32, LocVariable );
using ( IDataReader reader = db.ExecuteReader(command))
{
//Loop through cursor values & store them in code behind class-obj(s)
}
}
I thought this was not possible, since I am reading both the value and the cursor, because ..
, if only the param out then flag , I would use db.ExecuteNonQuery (..) & amp; if only the cursor, then , I would use db.ExecuteReader (..)
Sunny source
share