Is it possible to use commandType = text to call a stored procedure using System.Data.OracleClient

376 views Asked by At

I am using System.Data.OracleClient to connect to an Oracle database using Enterprise library and I would like to call a stored procedure using the commandType = Text as follows:

Microsoft.Practices.EnterpriseLibrary.Data.Database database = null;

database = DatabaseFactory.CreateDatabase("DbInstanceName");
System.Data.Common.DbConnection conn = database.CreateConnection();

conn.Open();

commandObj = database.GetSqlStringCommand("execute procName('paramValue1','paramValue2')");
commandObj.CommandType = CommandType.Text;
commandObj.Connection = conn;

returnCode = database.ExecuteNonQuery(commandObj);

I keep getting an invalid SQL statement error and would like to know if it is possible to use CommandType.Text for a stored procedure call into Oracle.

We cannot use the CommandType = StoredProcedure because the command string passed in includes all the parameter values to the stored procedure call within the string. If this is not possible, I would have to parse out each of the parameter values from the string and put them into parameter objects.

1

There are 1 answers

0
ptn77 On BEST ANSWER

This is possible. I found my problem to be the "execute" statement. This is not needed for Oracle stored procs.