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

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


...全文
106 2 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
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

754

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧