为何执行后在数据库没有生成数据
create proc p_test( @dt datetime, @ret int output ) as
declare @cnt int
select @cnt = count(*) from kqjl where datediff(m,rq,@dt) = 0
if @cnt > 0
begin
set @ret = 1
return
end
insert into kqjl(bh,xm,bm1,bm2,bm3,zglx,bm,rq,k01)
(select bh,xm,bm1,bm2,bm3,zglx,
((select rtrim(c.bmmc) from bm1 c where c.bm1 = a.bm1) + ( case when ( select rtrim(d.bmmcs) from bm2 d where d.bm2 = a.bm2 ) is null then '' else '/' + ( select rtrim(d.bmmcs) from bm2 d where d.bm2 = a.bm2 ) end ) + ( case when ( select rtrim(e.bmmcss) from bm3 e where e.bm3 = a.bm3 ) is null then '' else '/' + ( select rtrim(e.bmmcss) from bm3 e where e.bm3 = a.bm3 ) end ) ) as bm,
@dt,
CAST(DATEADD(MONTH,DATEDIFF(MONTH,0,getdate())+1,0)-DATEADD(MONTH,DATEDIFF(MONTH,0,getdate()),0)AS INT ) as ts
from ygml a)
set @ret = 0
C/C++ code
//代码
datetime ldt_rq
int li_ret
em_1.getdata(ldt_rq)
DECLARE P1 PROCEDURE FOR P_test
@dt = :ldt_rq,
@ret = :li_ret OutPut
;
EXECUTE P1;
IF sqlca.sqlcode <> 0 THEN
Messagebox( '', '执行失败' )
RollBack;
ELSE
FETCH P1 INTO :li_ret ;
Commit;
END IF
if li_ret > 0 then
messagebox( '','本月记录已经存在' )
return
end if
//刷新dw