为何执行后在数据库没有生成数据

simon505 2008-12-01 01:55:28
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


...全文
81 点赞 收藏 2
写回复
2 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
zijiezhuang 2008-12-01
到sql里面执行存储过程的内容 有可能插入的时候有主键有重复等原因
回复
liubocy 2008-12-01
--在sql中运行下看效果

declare @dt datetime, @ret int

set @dt = '2008-12-01'

exec p_test @dt, @ret output

select @ret
select * from kqjl where rq = @dt
回复
发帖
数据库相关
创建于2007-09-28

738

社区成员

PowerBuilder 数据库相关
申请成为版主
帖子事件
创建了帖子
2008-12-01 01:55
社区公告
暂无公告