SQL SERVER 7.0 中storeprocedure 的RETURN VALUE 如何使用(100分)

  • 主题发起人 主题发起人 wuhao
  • 开始时间 开始时间
W

wuhao

Unregistered / Unconfirmed
GUEST, unregistred user!
I have SQL server 7.0 storeprocedure like this :
create proc XXXXX ... as
if (condition) return(0)
else return(3)
when I use it in delphi 4 storeprocedure,the return value is always 0 not 3 even if it should return 3.I test in in SQl
query analyzer the SQL statement is ok.can you help me?




 
return 0 means the storeprocedure executes without errors.
You must declare a output variant to ruturn value.like this:
create proc XXX @result int output
as
if (condition) select @result=0
else select @result=3

when you run the storeprocedure,write like this:
declare @a int
exec XXX @result=@a output
select @a



 
把括号去掉看行不行.
 
This is solution way,I want to know how can I get SQL server 7.0 storeprocedure return value using result type variant in delphi 4.0 storeprocedure without declare output param in SQL server storeprocedure
 
例子:
var i:integer;
with query1 do begin
SQL.TEXT:='EXECUTE PROC1 :INPUTParam :OUTPUTParam';
ParamByname('INPUTParam').Asstring:='AC0022';
ParamByname('OUTPUTParam').DataType:=ftInteger;
ParamByname('OUTPUTParam').ParamType:=ftOutput;
ExecSQL;
i:=ParamByname('OUTPUTParam').value;
end
case i of
3 : {do something};
5 : {do something};
else
{do something};
end;
 
You could use the property of TQuery called Params
 
干脆你在storedproc里raiserror算了。
 
同意FX的看法,别人的说法都没有切中要害
关键是 MS SQL SERVER 的自定义返回值该为一变量
而不是常量
所以 return 0 不会成功
declare 一个变量
select 该变量=0
再 return 此变量即可
 
请继续讨论或结束问题!
 
不想结束要申请!
 
后退
顶部