包头:
create or replace package pack_frameportal is
--测试
procedure p1(x number);
procedure p2(y number);
end pack_frameportal;
包体:
create or replace package body pack_frameportal Is
--测试
procedure p1(x number) is
begin
--select t.numid from student t;
dbms_output.put_line(x);
end;
procedure p2(y number) is
TempID Number;
begin
select count(1) into TempID from STUDENT;
end;
end pack_frameportal;c#调用代码:
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Oracle9iConn"].ToString();
OracleConnection oraconn = new OracleConnection(connectionString); if (oraconn.State == ConnectionState.Closed)
{
oraconn.Open();
}
OracleCommand oracmd = new OracleCommand("pack_frameportal.p2", oraconn);
oracmd.CommandType = CommandType.StoredProcedure;
OracleParameter p1 = new OracleParameter(":y", OracleType.Number, 4);
p1.Direction = ParameterDirection.Input;
p1.Value = stuid;
oracmd.Parameters.Add(p1);
oracmd.ExecuteNonQuery();出现如下异常:ORA-06550: 第 1 行, 第 31 列:
PLS-00103: 出现符号 ":"在需要下列之一时:
( - + case mod new not null
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> avg count current exists max min prior sql
stddev sum variance execute forall merge time timestamp
interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
符号 ":" 被忽略。采用无参存储过程时都没有问题,应该就是参数传递出现了问题,该如何解决啊?
create or replace package pack_frameportal is
--测试
procedure p1(x number);
procedure p2(y number);
end pack_frameportal;
包体:
create or replace package body pack_frameportal Is
--测试
procedure p1(x number) is
begin
--select t.numid from student t;
dbms_output.put_line(x);
end;
procedure p2(y number) is
TempID Number;
begin
select count(1) into TempID from STUDENT;
end;
end pack_frameportal;c#调用代码:
string connectionString = System.Configuration.ConfigurationManager.ConnectionStrings["Oracle9iConn"].ToString();
OracleConnection oraconn = new OracleConnection(connectionString); if (oraconn.State == ConnectionState.Closed)
{
oraconn.Open();
}
OracleCommand oracmd = new OracleCommand("pack_frameportal.p2", oraconn);
oracmd.CommandType = CommandType.StoredProcedure;
OracleParameter p1 = new OracleParameter(":y", OracleType.Number, 4);
p1.Direction = ParameterDirection.Input;
p1.Value = stuid;
oracmd.Parameters.Add(p1);
oracmd.ExecuteNonQuery();出现如下异常:ORA-06550: 第 1 行, 第 31 列:
PLS-00103: 出现符号 ":"在需要下列之一时:
( - + case mod new not null
<an identifier> <a double-quoted delimited-identifier>
<a bind variable> avg count current exists max min prior sql
stddev sum variance execute forall merge time timestamp
interval date
<a string literal with character set specification>
<a number> <a single-quoted SQL string> pipe
符号 ":" 被忽略。采用无参存储过程时都没有问题,应该就是参数传递出现了问题,该如何解决啊?
改成:
OracleParameter p1 = new OracleParameter("@y", OracleType.Number, 4);
OracleParameter p1 = new OracleParameter(":y", OracleType.Number);
输入参数好像不要长度。。
还有冒号也不要
OracleParameter p1 = new OracleParameter("y", OracleType.Number);