存储过程 输入+ 输出 +返回+变量+参数

OracleParameter1.Direction =
ParameterDirection.Input:指定参数是输入参数;
ParameterDirection.Output:指定参数是输出参数;
ParameterDirection.InputOutput:参数即可输入也可输出;
ParameterDirection.ReturnValue:存储过程/函数的返回值;

 

declare @tmpd int  定义一个变量(作用:可以取值 并赋值)

实例:

declare @cid varchar(100),@username varchar(100)--用户姓名
select  top 1 @cid=id  from company where cname=@cname and ctel=@ctel order by id desc --客户id
select  top 1 @username=tname from userinfo where id=@uid--拥护名字
insert into userdoinfo(cid,uid,tname,dowhat)values(@cid,@uid,@username,'添加公司:'+@cname)

 

 

 

ParameterDirection.ReturnValue: (返回值类型:int   string 或其他,根据定义的返回该参数值())

@result  [varchar](50) output

 AS
select * from  company  where cname = @cname

  if (@@Rowcount > 0)
  begin ---------------------------------------------------
  set @result = 'E'
  end ------------------------------------------------------
 
  else
  begin ---------------------------------------------------
insert into company (carea,ckind,ccalling,csale,csize,cpers,uid,seruid,cfrom,csort,cname,caddr,cpost,cmail,ctel,ccz,chttp,ccometime,ccorp,cmome)values(@carea,@ckind,@ccalling,@csale,@csize,@cpers,@uid,@seruid,@cfrom,@csort,@cname,@caddr,@cpost,@cmail,@ctel,@ccz,@chttp,@ccometime,@ccorp,@cmome)
       declare @cid varchar(100),@username varchar(100)--用户姓名
select  top 1 @cid=id  from company where cname=@cname and ctel=@ctel order by id desc --客户id
select  top 1 @username=tname from userinfo where id=@uid--拥护名字
insert into userdoinfo(cid,uid,tname,dowhat)values(@cid,@uid,@username,'添加公司:'+@cname)

 if(@tname<>'')   -------------------------------加主要联系人
begin ---------------------------------------------------                    


insert into ccontact(tname,phone,mob,cz,msn,mail ,qq,job,bm,sex,sub,cid)values(@tname,@phone,@mob,@cz,@msn,@mail ,@qq,@job,@bm,@sex,@sub,@cid)
end ------------------------------------------------------

 set  @result='S'
                           end-

 

你可能感兴趣的:(存储过程)