New answers tagged

5

It's way easier in plpgsql: CREATE FUNCTION kraj_pilkarze(p_kraj varchar(30)) RETURNS VOID AS $$ DECLARE _r RECORD; _id_kraj int; _nazwa_zespolu text; BEGIN _id_kraj := id_kraj FROM kraj WHERE nazwa = $1; FOR _r IN SELECT imie, nazwisko, id_zespol, id_kraj FROM pilkarz LOOP IF r.id_kraj = _id_kraj THEN _nazwa_zespolu := nazwa FROM ...


0

Final code: (It works) ALTER TABLE public.companies ADD COLUMN client_code_increment integer; ALTER TABLE public.companies ALTER COLUMN client_code_increment SET NOT NULL; ALTER TABLE public.companies ALTER COLUMN client_code_increment SET DEFAULT 1000; COMMIT TRANSACTION; BEGIN; -- Creating the function CREATE OR REPLACE FUNCTION users_code_seq() ...



Top 50 recent answers are included