一个Sybase存储过程问题-------执行时出错,请大虾们进来看看
我要做的时,通过一个存储过程dbo.T_KJ_SWDJTJB调用另一个存储过程dbo.T_KJ_GET_SQL_SWDJTJB ,dbo.T_KJ_GET_SQL_SWDJTJB 将会返回一个SQL语句.
在dbo.T_KJ_SWDJTJB中,执行这个sql
请大家帮我看看 错在哪了
存储过程代码:
CREATE PROCEDURE dbo.T_KJ_SWDJTJB
@is_sjyf VARCHAR(6)
as
DECLARE
@ROWCOUNT INT,
@vs_xh VARCHAR(4),
@vs_xm VARCHAR(100),
@vs_bm VARCHAR(50),
@vs_tj VARCHAR(3000),
@vs_sql VARCHAR(10000),
@COMMITCOUNT INT
select @ROWCOUNT = 0
select @COMMITCOUNT = 0
BEGIN
--定义游标
DECLARE V_CUR CURSOR FOR
select XH,XM,BM,TJ from T_CS_KJ_SWDJTJB order by XH
--循环
OPEN V_CUR
FETCH V_CUR INTO @vs_xh,@vs_xm,@vs_bm,@vs_tj
WHILE @@SQLSTATUS != 2
BEGIN
EXEC dbo.T_KJ_GET_SQL_SWDJTJB @is_sjyf,@vs_bm,@vs_xh,@vs_xm,@vs_tj,@vs_sql output
IF @vs_sql IS NOT NULL
BEGIN
EXEC @vs_sql
END
FETCH V_CUR INTO @vs_xh,@vs_xm,@vs_bm,@vs_tj
END
CLOSE V_CUR
IF @@ERROR <> 0
BEGIN
ROLLBACK TRAN
RETURN -200
END
PRINT 'SUCCESS '
PRINT @vs_sql
END
RETURN 0
出错信息:
Error: Number (2812) Severity (16) State (8) Server (ESZDS) Procedure (T_KJ_SWDJTJB) Stored procedure 'insert into dbo.T_KJ_SWDJTJB_BO(
SJRQ,
GLJG_DM,
XH,
XM,
NLMY_SL ,
CKY_SL,
ZZY_SL,
DL_SL,
JZY_SL ,
JTYSY_SL ,
XXCS_SL ,
PFLS_SL ,
ZSCY_SL ,
' not found. Specify owner.objectname or use sp_help to check whether the object exists (sp_help may produce lots of output).
, Batch 1 Line 43
[解决办法]
EXEC (@vs_sql)