Hi, I am performing a POC with the ATS scheduler because the "Task Centre" is becomming obsolete, right?
If i understand it right my housekeeping scripts have to be transformed into housekeeping stored procedures first.
Looks easy enough but ..... when you execute a reorg in a loop the loop is broken. No matter how you specify it. Please look at my code:
Code:
create or replace
procedure runstats_schema3 ()
language sql
specific runstats_schema3
begin
declare global temporary table housekeeptabs
( table_schema varchar(128) not null
, table_name varchar(128) not null
) on commit preserve rows
not logged
on rollback preserve rows
;
insert into session.housekeeptabs
select table_schema , table_name
from sysibm.tables a
where a.table_type = ucase('base table')
and a.table_schema = current_schema
;
for L1 as
select varchar ('reorg table ' || rtrim (h.table_schema) || '.' || rtrim (h.table_name)) as db2_reorg_line
, varchar ('runstats on table ' || rtrim (h.table_schema) || '.' || rtrim (h.table_name)) as db2_runstats_line
from session.housekeeptabs h
order by h.table_name
do
call sysproc.admin_cmd (db2_reorg_line) ;
call sysproc.admin_cmd (db2_runstats_line) ;
end for;
end ~
As long as I only perform the "runstats" call everything works fine, but when I excute the reorg line the loops fails with a SQL0501. A cursor WITH HOLD does not do the job either.
This is basic stuff, what am I missing here?