AK <alk...@gmail.com> wrote: > I am reading the following in the documentation: "Tip: A common > mistake is to write a semicolon immediately after BEGIN. This is > incorrect and will result in a syntax error." > > So, "common mistake" means semicolons after BEGIN seem consistent > to many people - it seems consistent to me as well. If PostgreSql > allowed them, we would have one less rule to memorize, shorter > documentation, less mistakes and so on. In other words, without > this limitation PostgreSql would be slightly more useful, right? > > What am I missing? Why do we need this rule? How is it making > PostgreSql better?
I think it only seems confusing because PostgreSQL also uses BEGIN as a synonym for START TRANSACTION (and people tend to use the shorter synonym to save keystrokes). In plpgsql BEGIN is not a command, it is part of declaring a code block. Wouldn't these look funny to you?: IF x = 1 THEN; ... END IF; CASE; WHEN x = 1 THEN ... WHEN x = 2 THEN ... ELSE ... END; LOOP; ... END LOOP; etc. Why should BEGIN be different from the above when it is not a command, but part of declaring a code block? In the nearest analog in the SQL standard, the BEGIN/END block is called a compound statement, and like any other statement it is ended by a semicolon; the standard does not allow a semicolon after the BEGIN. -- Kevin Grittner EDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company -- Sent via pgsql-hackers mailing list (email@example.com) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers