使用 C# 创建 Oracle 过程
Create Oracle Procedure using C#
我正在使用 C# 创建过程
str = @"create or replace procedure awad
(O_MSG OUT VARCHAR2)
is
begin
O_MSG:='Executed Awad';
end;
";
store_cmd = new OracleCommand(str, store_con);
store_cmd.ExecuteNonQuery();
从我的代码中 运行ning 没有错误但是
该过程创建为无效,当我在 Toad 中编译它时,它向我显示以下错误
PROCEDURE 08903.AWAD On line: 1 PLS-00103: Encountered the symbol ""
when expecting one of the following: ( ; is with authid as cluster
compress order using compiled wrapped external deterministic
parallel_enable pipelined The symbol "" was ignored.
如果我复制相同的代码并运行它在 Toad 编辑器中它得到编译没有任何错误
您应该将 '(单引号)转义为 ''(两个单引号)。试试这个代码:
str = @"create or replace procedure awad
(O_MSG OUT VARCHAR2)
is
begin
O_MSG:=''Executed Awad'';
end;
";
store_cmd = new OracleCommand(str, store_con);
store_cmd.ExecuteNonQuery();
我上次使用 Oracle 时(虽然好像是 10 年前),由于 SQL 中的 CRLF,经常会出现这些错误。尝试
str = @"create or replace procedure awad
(O_MSG OUT VARCHAR2)
is
begin
O_MSG:='Executed Awad';
end;
".Replace("\r\n", "\n");
(虽然我必须说,如果这是问题所在,他们在 10 年多的时间里没有解决这个问题是非常不起眼的)。
我正在使用 C# 创建过程
str = @"create or replace procedure awad
(O_MSG OUT VARCHAR2)
is
begin
O_MSG:='Executed Awad';
end;
";
store_cmd = new OracleCommand(str, store_con);
store_cmd.ExecuteNonQuery();
从我的代码中 运行ning 没有错误但是 该过程创建为无效,当我在 Toad 中编译它时,它向我显示以下错误
PROCEDURE 08903.AWAD On line: 1 PLS-00103: Encountered the symbol "" when expecting one of the following: ( ; is with authid as cluster compress order using compiled wrapped external deterministic parallel_enable pipelined The symbol "" was ignored.
如果我复制相同的代码并运行它在 Toad 编辑器中它得到编译没有任何错误
您应该将 '(单引号)转义为 ''(两个单引号)。试试这个代码:
str = @"create or replace procedure awad
(O_MSG OUT VARCHAR2)
is
begin
O_MSG:=''Executed Awad'';
end;
";
store_cmd = new OracleCommand(str, store_con);
store_cmd.ExecuteNonQuery();
我上次使用 Oracle 时(虽然好像是 10 年前),由于 SQL 中的 CRLF,经常会出现这些错误。尝试
str = @"create or replace procedure awad
(O_MSG OUT VARCHAR2)
is
begin
O_MSG:='Executed Awad';
end;
".Replace("\r\n", "\n");
(虽然我必须说,如果这是问题所在,他们在 10 年多的时间里没有解决这个问题是非常不起眼的)。