ANTON KADACH

Generation

code to explanationWed, 18 Jan 2023

CREATE OR REPLACE FUNCTION UPDATE_VERSION_ID (DP_ID INT) RETURNS VOID LANGUAGE PLPGSQL AS $FUNCTION$ DECLARE vers_id int8; vers_actual_id int8; pt_id int8; ptr_id int8; dps_id int8; dpsa_id int8; fsa_id int8; begin select version_id from departmental_project where id = $1 into vers_id; create temp table temp_ver_id on commit drop as select v3.id from change_request.group_versions v join change_request.groups g on g.id = v.group_id join change_request.group_versions v2 on v2.group_id =g.id join change_request.version v3 on v3.id = v2.version_id and v3.version_is_actual where v.version_id =vers_id ; --Задача for pt_id in update project_tasks set version_id = vers_id where departmental_project_id = $1 and version_id in (select id from temp_ver_id) returning id loop for ptr_id in update project_task_results set version_id = vers_id where project_task_id = pt_id and version_id in (select id from temp_ver_id) returning id loop for dps_id in update departmental_project_sources set version_id = vers_id where result_id = ptr_id and version_id in (select id from temp_ver_id) returning id loop for dpsa_id in update departmental_project_source_attributes set version_id = vers_id where departmental_project_source_id = dps_id and version_id in (select id from temp_ver_id) returning financial_source_attribute_id loop update financial_source_attributes set version_id = vers_id where id = dpsa_id and version_id in (select id from temp_ver_id); end loop; end loop; end loop; end loop; --Результат end; $FUNCTION$ ;

- In the end of the article write the final code (with all changes). ## Versioning - When you have finished the article, mark it with `status: to_review`. - The article is reviewed by a colleague, it makes changes if necessary. - If the article does not need to be changed, it is marked with the `status: ready`. - If the article needs to be changed, the article is marked with the `status: in_progress`. - If the article has been changed, it is marked with `status: to_review`. - When the article has the status `ready`, it is possible to mark it with the `status: published`. ### Example 1. Create article:

Questions about programming?Chat with your personal AI assistant