Click here to Skip to main content
15,888,527 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have an oracle script which is having a procedure say below stored at some location.

create or replace procedure test
is
begin

update testTable
set input=1
where input2=4;
end test;

....
What I have to do is to fetch this script using C #..create this proc through C# code and then execute it...

This is code i have written..

C#
public void Something()
{

string path= "something";
FileInfo files= new FileInfo(path);
string script = files.OpenText().ReadToEnd();
OracleCommand cmd= new OracleCommand(conn);
cmd.CommandText = script;
cmd.ExecuteNonQuery();  //this will create the proc..

cmd.CommandType=CommandType.StoredProcedure;
cmd.CommandText= "test";
cmd.cmd.ExecuteNonQuery();  //to execute the proc. but i am facing pls 00905 error.

}


Above i am facing error 00905 object is invalid error...
I having with creating a transaction and commiting it but have not worked.
Also tried to use the schema name with the proc but the same error.

I am sure that the proc is just created and it is not compiling ...
coz just after creating the proc through and without executing it through code;
If i execute it through the database then also the same error.

This doesnt seems to be the roles and rights issue...just I need that proc should be created and compile.

Please if any one can help me this.
Sorry . I didnt mentioned that I am also creating that table (test) before the proc through code...i.e fetching the script of the table and executing it..and in the proc I am using that table...may be if that is causing the issue..
Posted
Updated 8-Apr-14 1:59am
v3
Comments
Prasad Khandekar 8-Apr-14 7:45am    
Please check the procedure script. The Object is Invalid error means that there are compilation errors in the proc.
Member 10733096 8-Apr-14 7:50am    
The proc I have written have executed it through database...no compilations errors faced..
ZurdoDev 8-Apr-14 7:55am    
You're sure the code actually creates the proc properly?
Member 10733096 8-Apr-14 8:02am    
the proc I checked thorugh backend i.e databse and it does created ..
Prasad Khandekar 8-Apr-14 8:18am    
Use SHOW ERRRORS to get more info while running the proc script in SQLPlus.

1 solution

it worked now :)....the issue was that the proc which I was using
consisted of exception hadling as that if any exception occurs then dbms output line step was written .. I just thoguht commented it out and then create and executed the proc through code..and it worked ...I didnt get why this happening in this way..any answers would be helpful...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900