We came across the below procedure that runs daily and we're not exactly sure what it does. Some of our workflow escalations don't work as expected (they get rejected instead of going to the next approver), and thought maybe this has something to do with it. Will someone please help me interpret this procedure? Thanks! Lisa
create
procedure
[dbo].[wfScanForOverdueTasksCompany]
@O_iErrorState
int
=
NULL
output
as
declare
@
count
as
integer
declare
@exestring
as
varchar
(400)
declare
@curcompany
as
varchar
(10)
--if the temp table exists, delete it
if exists (
select
*
from
dbo.sysobjects
where
id = Object_id(
'dbo.#wfEscalateTemp'
)
and
type
in
(
'U'
,
'S'
))
begin
drop
table
dbo.#wfEscalateTemp
end
--create a temp table that contains all the GP company databases
select
INTERID
into
#wfEscalateTemp
from
SY01500
--find out how many there are
select
@
count
=
count
(*)
from
#wfEscalateTemp
--loop through the company databases
while @
count
> 0
begin
--get the first one
select
@curcompany = (
select
top
1(INTERID)
from
#wfEscalateTemp)
--create a string to be executed
select
@exestring = @curcompany +
'.dbo.wfScanForOverdueTasks'
--execute the string
if exists(
select
name
from
master..sysdatabases
where
name
= @curcompany)
begin
print @exestring
exec
@exestring
end
--delete this line in the temp table
delete
from
#wfEscalateTemp
where
INTERID = @curcompany
--update the count, and loop
select
@
count
=
count
(*)
from
#wfEscalateTemp
end
return