Enterprise Library with Oracle and ExecuteScalar
I recently had to flip from using the standard Oracle Data Access Library
to implementing it inside of the Enterprise Library due to a coding
standards issue. All my logic seems to be working out fine so far, except
I'm having an issue with the Execute Scalar. The other queries function
correctly (Non-Scalar calls, inserts, updates, deletes, etc) but I'm hung
up on these scalar values.
Stored Procedure:
PROCEDURE "GET_VIEW_COUNT"
(whereClause IN VARCHAR2,
o_rc OUT sys_refcursor)
is
rowQuery varchar2(32000);
begin
rowQuery := 'SELECT COUNT(*) FROM My_VW WHERE ' || whereClause;
OPEN o_rc FOR rowQuery;
end;
C# Code
Database database =
DatabaseFactory.CreateDatabase(DataCommon.GetConnectionStringStatic());
using (DbCommand command =
database.GetStoredProcCommand("GET_VIEW_COUNT"))
{
database.DiscoverParameters(command);
database.SetParameterValue(command, "whereClause",
whereClause);
totalRows = (decimal)database.ExecuteScalar(command);
}
However the issue is that ExecuteScalar always returns null. Running the
query straight up returns a 1 column 1 row table (just the count). This
worked previously using the old Oracle.DataAccess but now that it's in the
EntLib I can't get it to work.
No comments:
Post a Comment