Reputation: 890
I am trying to run this C# code
string sql = @"EXECUTE GETEMPLOYEES1()";
OracleCommand cmd = new OracleCommand(sql, cnn);
cmd.CommandType = CommandType.Text;
cmd.ExecuteNonQuery();
but I keep getting
Invalid SQL error
My stored procedure code is very simple
CREATE OR REPLACE PROCEDURE GETEMPLOYEES1
AS
BEGIN
DBMS_OUTPUT.PUT_LINE('Welcome to FYICenter!');
END;
I am able to run it normally by using CommandType = StoredProcedure
but I need to execute some dynamic code entered by the user and it is vital to me to do it by CommandType = Text
.
Upvotes: 1
Views: 914
Reputation: 5809
EXECUTE
is a SQL*Plus command. Use either
CALL GETEMPLOYEES1()
or
BEGIN GETEMPLOYEES1(); END;
Also if you choose command type StoredProcedure the library adds BEGIN ... END;
internally for you.
CALL
also requires empty parentheses when a procedure is parameterless.
Upvotes: 1
Reputation: 1422
Try replacing DBMS_OUTPUT.PUT_LINE('Welcome to FYICenter!');
with null;
, and see if that makes it any different. Im asuming in connection context there is no sense to try to output text, there is no console.
Upvotes: 0