There's no way to do this in an ANSI mode SP.
If you can't switch to TD mode there's a workaround:
Don't EXECUTE the DDLs, but insert all of them into a Volatile Table adding a sequence number. Then run a second loop (based on the previous activity_count) to SELECT the individual DDL statements (WHERE seqence number = x) and EXECUTE/COMMIT each.
There's no way to do this in an ANSI mode SP.
If you can't switch to TD mode there's a workaround:
Don't EXECUTE the DDLs, but insert all of them into a Volatile Table adding a sequence number. Then run a second loop (based on the previous activity_count) to SELECT the individual DDL statements (WHERE seqence number = x) and EXECUTE/COMMIT each.
Dieter