You need to use "dynamic SQL that returns a result set", something like this:
DECLARE SqlStr VARCHAR(1000);
DECLARE C1 CURSOR FOR S1;
SET SqlStr = 'SELECT COUNT(*) FROM '||a||'.'||T_name;
PREPARE S1 FROM SqlStr;
OPEN C1;
FETCH C1 INTO DB_A_CT;
CLOSE C1;
You need to use "dynamic SQL that returns a result set", something like this:
DECLARE SqlStr VARCHAR(1000);
DECLARE C1 CURSOR FOR S1;
SET SqlStr = 'SELECT COUNT(*) FROM '||a||'.'||T_name;
PREPARE S1 FROM SqlStr;
OPEN C1;
FETCH C1 INTO DB_A_CT;
CLOSE C1;