create or replace procedure zzinert
(
p_out out number,
pemail users.email%type,
pwd users.password%type,
aid users.adminid%type,
gid users.groupid%type
)
as
UserID number;
EMail varchar2(50);
PassWord varchar2(32);
AdminID number;
GroupID number;
v_count number;
begin
p_out:=0;
select count(*) into v_count from users where EMail=pemail;
if v_count>=1 then
p_out:=-1; --该用户名已经存在
return;
end if;
insert into users (UserID,EMail,PassWord,AdminID,GroupID) values (seq_users_id.nextval,pemail,pwd,aid,gid);
end;请问,我如何在C#代码中获得这个p_out??public int Insert(UserInfo info)
{
string SELECT = "zzinert";
OracleParameter[] parm = new OracleParameter[] {
new OracleParameter("p_out",OracleType.Int32),
new OracleParameter("pemail",OracleType.VarChar,50),
new OracleParameter("pwd",OracleType.VarChar,32),
new OracleParameter("aid",OracleType.Int32),
new OracleParameter("gid",OracleType.Int32)
};
parm[0].Value = ??????;
parm[1].Value = info.EMail;
parm[2].Value = info.PassWord;
parm[3].Value = info.AdminID;
parm[4].Value = info.GroupID;
int returnValue = 0;
using (OracleConnection conn = new OracleConnection(OracleHelper.ConnectionStringLocalTransaction))
{
conn.Open();
using (OracleTransaction trans = conn.BeginTransaction())
{
try
{
returnValue = OracleHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, SELECT, parm);
trans.Commit();
}
catch (OracleException err)
{
trans.Rollback();
string sMethod = "OracleDAL.User.Insert()";
EventsLog.WriteLog(err, sMethod);
}
}
}
return returnValue;
}
请高手们速度,谢谢!!!
解决方案 »
- 感谢各位~~
- 10204_vista_w2k8_x64_production_db 在wen7 64位系统安装待解决
- 求Oracle中国用户讨论组CNOUG邀请码
- cnoug网站好久不能打开了
- 急,我oracle安装后一切正常,但我重启动后出现下列问题,求助!!
- 二表复制问题
- 哪位XDJM有Developer 2000,或知道下载的地址,小弟不胜感激
- 请问什么是 PL/SQL?
- oracle数据库的internet连接问题
- 紧急求助: 在执行SQL语句时出现如下提示:ORA-03232: unable to allocate an extent of 46 blocks from tablespace 3
- 求一条语句的错误
- 求一sql语句
parm[0] 就是你要的p_out,
在运行procedure 之后,
你把parm[0]打印出来看看
try
{
returnValue = OracleHelper.ExecuteNonQuery(trans, CommandType.StoredProcedure, SELECT, parm);
info.outvalue = parm[0].Value;
trans.Commit();
}可得到的还是初始的那个parm[0].Value = ??????;
parm[0].Value = ??????;
换成
parm[0].Direction = ParameterDirection.Output;自己忘记了,晕。.....快来人拿分呀。
===Create procedure in oracle==================================
SQL> create or replace procedure my_pro_out(param1 out varchar2)
2 as
3 begin
4 param1 := 'This is a testing!';
5 end;
6 /Procedure created=====delphi testing source code========================
var
my_out: String;
begin
ADOStoredProc1.Parameters.ParamByName('param1').Value := my_out;
ADOStoredProc1.ProcedureName := 'my_pro_out';
ADOStoredProc1.ExecProc;
my_out := ADOStoredProc1.Parameters.ParamByName('param1').Value;
//The my_out value equals to 'This is a testing!'
end;比可以参考一下