Generation

text to sql syntaxMon, 20 Mar 2023

Insert data if study_uid is unique or update all fields if study_uid already exist with increment update_version field, and save old data to history table "Schema","Table","Column","Type" ods,conclusion_f,id,integer ods,conclusion_f,last_validation,timestamp without time zone ods,conclusion_f,update_version,integer ods,conclusion_f,active_from,timestamp without time zone ods,conclusion_f,active_to,timestamp without time zon ods,conclusion_f,recommendation,character varying ods,conclusion_f,origin,character varying ods,conclusion_f,last_doctor_name,character varying ods,conclusion_f,last_doctor_code,character varying ods,conclusion_f,study_uid,character varying

INSERT INTO conclusion_f (last_validation,update_version,active_from,active_to,recommendation,origin,last_doctor_name,last_doctor_code,study_uid) VALUES ('2019-10-01', 1, '2019-10-01', '2019-10-01', 'test', 'test', 'test', 'test', 'test') ON CONFLICT (study_uid) DO UPDATE SET last_validation = EXCLUDED.last_validation, update_version = conclusion_f.update_version + 1, active_from = EXCLUDED.active_from, active_to = EXCLUDED.active_to, recommendation = EXCLUDED.recommendation, origin = EXCLUDED.origin, last_doctor_name = EXCLUDED.last_doctor_name, last_doctor_code = EXCLUDED.last_doctor_code RETURNING * INTO ods.history_conclusion_f;

Questions about programming?Chat with your personal AI assistant