Reputation: 31
I don't understand why I get an error on the line with the : "END $$"
DO $$
BEGIN
DECLARE
i INT := 0;
j INT := i + 1;
numberUsers INT;
BEGIN
SELECT COUNT(*) INTO numberUsers FROM "WU_Users";
WHILE i <= numberUsers LOOP
i := i + 1;
END LOOP;
END $$;
The error :
ERREUR: erreur de syntaxe à la fin de l'entrée
LIGNE 12 : END $$;
Kind Regards !
Upvotes: 0
Views: 475
Reputation: 246588
Indent properly, then it will become clear. The block structure is
DECLARE /* optional */
BEGIN
EXCEPTION /* optional */
END;
To format your code:
DO $$
BEGIN
DECLARE
i INT := 0;
j INT := i + 1;
numberUsers INT;
BEGIN
SELECT COUNT(*) INTO numberUsers FROM "WU_Users";
WHILE i <= numberUsers LOOP
i := i + 1;
END LOOP;
/* --> missing END; here <--- */
END $$;
Alternatively, you could remove the BEGIN
at the beginning, since that outermost block just contains another block.
Upvotes: 1