ALTER PROCEDURE [dbo].[ken_overtime_check](@p_use_code
nvarchar(100),@p_table_name nvarchar(1000))
AS
BEGIN
declare @cursor_name cursor;
declare @employeeid
nvarchar(100);
declare @cur_employeeid nvarchar(1000);
SET NOCOUNT ON;
begin try
begin transaction ;
SET @sql =
‘SELECT @tc_1 = EMPLOYEEID FROM ‘+@p_table_name;
exec sp_executesql
@sql,N‘@tc_1 nvarchar(100) output‘,@cur_employeeid out;
set @cursor_name = Cursor for select @cur_employeeid ;
open
@cursor_name
fetch from @cursor_name into @employeeid
while
@@fetch_status = 0
begin
fetch from @cursor_name into
@employeeid
update Temp_1120367_201402261323358787 set HOURS =
HOURS+1;
end
close @cursor_name
commit transaction ;
--set @v_out_str=‘True‘;
set @v_out_str =
@p_table_name;
select @v_out_str;
end try
begin
catch
if @@ERROR=66666 begin -- 通过@@ERROR的值来判断是否是自定义的异常
--set @p_outstr
= @v_out_str;
set @v_out_str = @v_out_str;
end
else
begin
--set @p_outstr = (select ERROR_MESSAGE());
set @v_out_str =
(select ERROR_MESSAGE());
end;
rollback transaction ;
select
@v_out_str;
--return;
end catch;
END