ANTON KADACH

Generation

text to sql syntaxWed, 01 Feb 2023

функция, которая циклом проходится по всем регионам и сохраняет каждый цикл результат в файл. plpgsql

CREATE OR REPLACE FUNCTION add_data() RETURNS TABLE(regname text, number INT, salary INT) AS $BODY$ DECLARE regname text; number INT; salary INT; BEGIN FOR regname IN select name from region LOOP select count(name), sum(salary) from employee where region=regname INTO number, salary; RETURN NEXT; END LOOP; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100 ROWS 1000;

Questions about programming?Chat with your personal AI assistant