SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE staff_schedule ( dogs_count integer, day date ); CREATE OR REPLACE PROCEDURE add_dog_to_schedule(in date) LANGUAGE sql AS $$ UPDATE staff_schedule SET dogs_count = dogs_count + 1 WHERE day = $1; $$; CREATE OR REPLACE PROCEDURE add_dog_to_schedule(v_from date, v_to date) LANGUAGE plpgsql AS $$ DECLARE v_r record; BEGIN FOR v_r IN SELECT date FROM generate_series(v_from, v_to, '1 day') d LOOP CALL add_dog_to_schedule(v_r.date); END LOOP; END; $$;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear