Noah Noah - 28 days ago 7
SQL Question

Simplify easy LOOP queries to get rid of the LOOP

Are there ways to Simplify this loop so that there is no loop needed?

FOR i IN 1 .. 2
LOOP
IF i = 1
THEN
give_bonus (president_id, 2000000);
ELSIF i = 2
THEN
give_bonus (ceo_id, 5000000);
END IF;
END LOOP;

Answer

You can simply call the procedures:

give_bonus (president_id, 2000000);
give_bonus (ceo_id, 5000000);
Comments