hi,
We would like to copy a record with 5 detail tabs, 100+ columns. Is there an option to do this without having to write a transaction and updating this every time a column has changed?
hi,
We would like to copy a record with 5 detail tabs, 100+ columns. Is there an option to do this without having to write a transaction and updating this every time a column has changed?
Best answer by Mark Jongeling
Maybe this will give you a head start š
insert into #prog_object_item
(
prog_object_id,
prog_object_item_id,
order_no,
template_id
)
select
'task_copy_data',
'task_copy_data_' + t.tab_id,
10,
'template_name'
from tab t
where t.model_id = @model_id
and t.branch_id = @branch_id
and t.type_of_table = 0 -- Only tables
insert into #prog_object_item_parmtr
(
prog_object_id,
prog_object_item_id,
parmtr_id,
parmtr_value,
order_no,
no_line_when_empty
)
select
'task_copy_data',
'task_copy_data_' + t.tab_id,
'COL',
c.col_id,
c.abs_order_no,
0
from tab t
join col c
on c.model_id = t.model_id
and c.branch_id = t.branch_id
and c.tab_id = t.tab_id
where t.model_id = @model_id
and t.branch_id = @branch_id
and t.type_of_table = 0 -- Only tables
and c.calulated_field_type = 0 -- Only non-calculated fields
insert into #prog_object_item_parmtr
(
prog_object_id,
prog_object_item_id,
parmtr_id,
parmtr_value,
order_no,
no_line_when_empty
)
select
'task_copy_data',
'task_copy_data_' + t.tab_id,
'COMMA',
case max(c.abs_order_no) over (partition by c.tab_id)
when c.abs_order_no then ' '
else ', '
end,
c.abs_order_no,
0
from tab t
join col c
on c.model_id = t.model_id
and c.branch_id = t.branch_id
and c.tab_id = t.tab_id
where t.model_id = @model_id
and t.branch_id = @branch_id
and t.type_of_table = 0 -- Only tables
and c.calulated_field_type = 0 -- Only non-calculated fields
(This can indeed be quite complex, but this will make is dynamic. So if any table names or column names change, the procedure will be adjusted accordingly)
Note that you may need to look into the ref table to find the references from the object you want to start copying.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.