ANTON KADACH

Generation

text to sql syntaxWed, 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$ ;

#### create table with column that has a specific data type

Questions about programming?Chat with your personal AI assistant