tags:

views:

474

answers:

4

Hi,

A beginner question: I have a stored proc (just a procedure, without any packages) in the Oracle Database:

CREATE OR REPLACE procedure FII_DBO.CLEAR_UNIT_TEST_PRODUCT
IS
BEGIN
 ...
END CLEAR_UNIT_TEST_PRODUCT;

and it works fine in TOAD. However, when I try to run it from C# it complains:

System.Data.OracleClient.OracleException: ORA-06550: line 1, column 7:
PLS-00201: identifier 'CLEAR_UNIT_TEST_PRODUCT' must be declared
ORA-06550: line 1, column 7:
PL/SQL: Statement ignored

relevant C# code:

Command = new OracleCommand();
Command.CommandText = procedureName;
Command.CommandType = CommandType.StoredProcedure;
Command.Connection = connection;
Command.ExecuteNonQuery();
A: 

Are you including the package name in the procedureName variable?

i.e. setting procedureName to "FII_DBO.CLEAR_UNIT_TEST_PRODUCT", not just "CLEAR_UNIT_TEST_PRODUCT"?

Ian Nelson
Yeah, tried that as well: identifier 'FII_DBO.CLEAR_UNIT_TEST_PRODUCT' must be declared
Grzenio
A: 

Your procedure seems to be created in another schema.

Issue

ALTER SESSION SET CURRENT_SCHEMA = FII_DBO

right after connecting.

I recall the provider has some bugs with calling stored procedures.

Set your CommandText to

BEGIN FII_DBO.CLEAR_UNIT_TEST_PRODUCT(); END;

and CommandType to Text

Also you may try to change the case of you stored procedure name, like:

fii_dbo.clear_unit_test_product

, I recall that the case matters too.

Quassnoi
+1  A: 

Check that the Oracle user that your .NET application is connecting with has permissions to execute the stored procedure.

Ian Nelson
yeah, that was the problem
Grzenio
+1  A: 

Found it, the error message was a bit misleading. I was executing it as a different user, who didn't have the proper access rights. This did the trick:

grant execute on FII_DBO.CLEAR_UNIT_TEST_PRODUCT to FII_USER;
Grzenio
Yeah, the error message is less than helpful, but I guess the thinking is that it's done for security purposes. If the user can't access the stored procedure, then the database won't even admit to its existence.
Ian Nelson