关于VF+SQL程序中的SQLEXEC()函数使用的问题。
关于VF+SQL程序中的SQLEXEC()函数使用的问题。
我做这段程序的思路是这样的:先在SQL上建一个存储过程,用于判断删除条件是否成立,
然后在vf中调用此存储过程,如果不能删除资料时,则根据返回值m1作出对应的中文提示。
一:在SQL7中所建的存储过程如下:
CREATE PROCEDURE [del_tr_shch1] @shenchid31 char(8), @YourError int output
AS
declare @shul31 int
set @YourError = 0
set @shul31=-1
select @shul31 = shu_bt from tr_shch_dd where tr_shch_dd.shenchid = @shenchid31
if (@shul31>=0) set @YourError = 1
else
begin
if (@YourError = 0) select @shul31 = shul from tr_yll where tr_yll.shenchid = @shenchid31
if (@shul31>=0) set @YourError = 2
else
begin
if (@YourError = 0) select @shul31 = shul from tr_shch3 where tr_shch3.shenchid = @shenchid31
if (@shul31>=0) set @YourError = 3
else
begin
if (@YourError = 0) select @shul31 = shul from tr_chpr where tr_chpr.shenchid = @shenchid31
if (@shul31>=0) set @YourError = 4
end
end
end
if (@YourError = 0)
begin
delete from tr_shch1 where (tr_shch1.shenchid = @shenchid31 and tr_shch1.shu_tl = 0)
delete from tr_shch2 where (tr_shch2.shenchid = @shenchid31)
end
二:在SQL Query中用如下语句测试时,一切正常。
declare @shenchid31 int,@m1 int
set @shenchid31 = '10000001'
exec del_tr_shch1 @shenchid31, @m1 output
三:在VF中用如下语句调用,每当运行到SQLEXEC()处时,总会提示错误(Operator/operand type mismatch)
LOCAL shenchid31,m1
m1=0
SELE tr_shch1
shenchid31=allt(tr_shch1.shenchid)
IF messagebox("你确定要删除目前的这一笔生产指令吗?",4+32+256)=6
sele tr_shch1
=SQLEXEC(myconnect,'exec del_tr_shch1 '+ shenchid31 +','+m1 output)
DO case
CASE m1=1
MESSAGEBOX('此生产指令'+shenchid31+' 还有订单投料明细存在,不可删除!')
CASE m1=2
MESSAGEBOX('此生产指令'+shenchid31+' 已经有发料,不可删除!')
CASE m1=3
MESSAGEBOX('此生产指令'+shenchid31+' 已经有输入在线完成/(报废)数量,不可删除!')
CASE m1=4
MESSAGEBOX('此生产指令'+shenchid31+' 已经有输入库数量,不可删除!')
ENDCASE
ENDIF
请问:
1. SQLEXEC(myconnect,'exec del_tr_shch1 '+ shenchid31 +','+m1 output)这一语句错在哪里?应该怎样写?
2. 假如换一种方式,在del_tr_shch1存储过程尾部,使用return m1返回值,请问用SQLEXEC()语句又应如何写?