Correct, with Tasks it's a little different. While with Defaults the Program objects are there for every table (and task and reports), for Tasks there is only 1; the Task itself. What you can do is create multiple entries for Program object item. For the Task that would mean its code will be long as it all depends how many tables it needs to cover.
First of you need a generic template that would work for all tables. Then write the neccesary code to replace all these parameters for the correct values. In this case it is needed to create an entry in prog_object_item for each table, so take the Tables (either from tab or tab_tag if it has one) and create items. This will mean the result will feature 1 Task that consist out of 1 Template that is duplicated for each table.
For each duplication we want to replace the parameters. If you have 1 parameters, one insert statement into prog_object_item_parmtr will do, but with multiple parameters, you'll have to union all the results, 1 select for parameter 1 and 1 select for parameter 2. This is the most easy way to do it. There's an alternative by cross joining a (Values) but it may not fit the solution anymore when using more than 2 parameters. Sometimes they also require more/different tables to be joined. so I suggest making use of Union all.
After that, if the code is correct, generate the code group and thereafter the definition of the Task and see the result. If everything goes well, there's one Program object and X-amount of Program object items that together make the complete procedure. To make sure the execution of the Task executes in the correct table, be sure to have a Task parameter with the table name for example. You can add to all tables a hidden expression column with the table name as value. But if there's any other way you can distinguish that, that is also possible of course.
For example, the template could look like this:
if @table_name = '[table]'
begin
insert into [table] (time_stamp)
select getdate()
end
Then the result could look like this:
create procedure community_example (
@table_name varchar(200)
)
as
begin
SET NOCOUNT ON;
if @table_name = 'Product'
begin
insert into [table] (time_stamp)
select getdate()
end
if @table_name = 'Relation'
begin
insert into [table] (time_stamp)
select getdate()
end
if @table_name = 'Country'
begin
insert into [table] (time_stamp)
select getdate()
end
if @table_name = 'Employee'
begin
insert into [table] (time_stamp)
select getdate()
end
end
You can also add a [col] parameter and add columns to the insert, by using string_agg() for example. This way you can get all col_id's from the tab and select it comma separated.