请问我写个存储过程(不知道对不对) 返回一个数 我调用时如何取得返回的值CREATE PROCEDURE land
@username VARCHAR(50),
@pwd VARCHAR(50)
AS
IF(SELECT USERNAME FROM MENBERTABLE where username=@username )=1
BEGIN
RETURN 1
ENDELSE
BEGIN
RETURN 2
END
GO ****************************
Connection con=null;
CallableStatement cs=null;
try{
cs=con.preparecall("{Call land(?,?)}");
cs.setString(1,"x");
cs.setString(2,"x");
cs.execate();
*****//这点怎么写,如何取返回的值//*****
}
catch(Exception ex)
{
}
@username VARCHAR(50),
@pwd VARCHAR(50)
AS
IF(SELECT USERNAME FROM MENBERTABLE where username=@username )=1
BEGIN
RETURN 1
ENDELSE
BEGIN
RETURN 2
END
GO ****************************
Connection con=null;
CallableStatement cs=null;
try{
cs=con.preparecall("{Call land(?,?)}");
cs.setString(1,"x");
cs.setString(2,"x");
cs.execate();
*****//这点怎么写,如何取返回的值//*****
}
catch(Exception ex)
{
}
@username VARCHAR(50),
@pwd VARCHAR(50),
@result VARCHAR(20) output-----存储过程output关键字用来存储返回值
AS
...set @result=1-----给返回值赋值便可,不用return...
程序中调用:
cs=con.preparecall("{Call land(?,?,?)}");
cs.setString(1,"x");
cs.setString(2,"x");
//注册输出参数类型
cs.registerOutParameter(3,java.sql.Types.VARCHAR);
cs.execate();
//得到输出参数的值
String result=cs.getString(3);