---    
---- toto v tejto chvili nepotrebujeme, ale dalo by sa to pouzit na nastavenie sekvencii pri vytvarani tabulky, pripadne pri doplnani stlpcov idriadok, ....
DO
$$
DECLARE maxid BIGINT;
			maxid2 BIGINT;
BEGIN
SELECT MAX(idriadok) into maxid FROM food600.adct;
SELECT nextval('food600.adct_idriadok_seq') into maxid2;
IF maxid IS NOT NULL THEN
	IF maxid+1<>maxid2 THEN
		PERFORM setval('food600.adct_idriadok_seq', maxid, true);
	END IF;
ELSE
	IF maxid2<>1 THEN
		PERFORM setval('food600.adct_idriadok_seq', 1, true);
	END IF;
END IF;

END
$$
