I have a stored procedure which accepts single varchar argument, I want to call this for each distinct id present in my table.
CREATE OR REPLACE FUNCTION updateData(i varchar(12)) RETURNS VOID AS $$
BEGIN
update employee set employee_number = nextval('d_employeeNumber_seq') where employee.age > 25 and employee.deptId = i;
ALTER SEQUENCE d_employeeNumber_seq RESTART WITH 1;
END;
$$ LANGUAGE plpgsql;
Now I want to call this updateData() for each department
something like select updateData() in (select distinct deptId from employee) [This isnt the correct syntax but i want to use something of this sort]
functionand not astored procedure. Syntax to invokestored procedureis different.