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
.
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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.