存储过程的返回值问题,为什么在查询分析器里执行正确,可以在PB里就不对那?
我在SQLSERVER里写了一个存储过程如下:
--目的:解决托运单自动编号问题
--说明:当当天的编号没有时,取出编号为1,更新wl_tbconsignforms_sequence的编号为2
-- 否则,取出当前编号,并把wl_tbconsignforms_sequence的编号加1
use iwwlms
if exists (select name from sysobjects where name = 'wl_tbconsignforms_squence'
and type='p')
drop procedure wl_tbconsignforms_squence
go
create procedure wl_tbconsignforms_squence
@create_date Varchar(7),
@consign_form_no int OUTPUT
as
if (select max(right("Consign_Form_No",4)) from wl_tbconsignforms
where left(Consign_Form_No,7) =@create_date ) is null
BEGIN
select @consign_form_no=1 from wl_tbconsignforms_sequence
update wl_tbconsignforms_sequence set consignform_seq=2
END
if @@Error <> 0
begin
Rollback
RaisError('....',16,1)
return
end
else
BEGIN
select @consign_form_no=consignform_seq from wl_tbconsignforms_sequence
update wl_tbconsignforms_sequence set consignform_seq=consignform_seq+1
END
if @@Error <> 0
begin
Rollback
RaisError('....',16,1)
return
end
go
在查询分析器里执行正常,执行语句如下:
-- Declare the variable to receive the output value of the procedure.
DECLARE @no Varchar(20)
-- Execute the procedure with a title_id value
-- and save the output value in a variable.
EXECUTE wl_tbconsignforms_squence
"T041204", @consign_form_no = @no OUTPUT
-- Display the value returned by the procedure.
PRINT @no
GO
但是在PB里执行为什么没有返回值?执行语句如下:
long ll_consign_no
DECLARE wl_tbconsignforms_squence PROCEDURE FOR wl_tbconsignforms_squence @create_date='T041201';
execute wl_tbconsignforms_squence;
fetch wl_tbconsignforms_squence into :ll_consign_no;
close wl_tbconsignforms_squence;
commit;
messagebox('ll_consign_no',ll_consign_no)
message的值总是0