ANTON KADACH

Generation

text to sql syntaxWed, 18 Jan 2023

Write a function that updates version_actual_period_start with type timestamp. Look for an entry with the condition version_actual_period_end > current_timestamp . the user specifies the desired date, and the previous one, according to the time of the relevance of the record, is updated version_actual_period_end-becomes the same, but 1 second less. Input parameters time, database table name, version_meta_id array. Plpgsql

CREATE or REPLACE FUNCTION public.update_actual_period_start_by_time(time timestamp, version_meta_id int[], table_name text) RETURNS void LANGUAGE plpgsql AS $function$ declare sql_text text; begin sql_text := format('UPDATE %I SET version_actual_period_start = %L, version_actual_period_end = %L WHERE version_meta_id = ANY(%L);', table_name, time, time - interval '1 sec', version_meta_id); execute sql_text; end; $function$

Questions about programming?Chat with your personal AI assistant