I'm new using PostgreSQL, I'm looking for more information about errors, for example if I run this:
select top 10 * from TABLE
I'm getting this error:
ERROR: syntax error at or near "10"
LINE 2: select top 10 * from TABLE
^
SQL state: 42601
Character: 13
I'm expecting to get something more. So, I've tried this from here https://www.postgresql.org/docs/current/plpgsql-control-structures.html#PLPGSQL-EXCEPTION-DIAGNOSTICS-VALUES but is not working (or I don't understand how to use it):
DECLARE
text_var1 text;
text_var2 text;
text_var3 text;
BEGIN
SELECT TOP 10 * FROM tbl; -- obviously incorrect
EXCEPTION WHEN OTHERS THEN
GET STACKED DIAGNOSTICS text_var1 = MESSAGE_TEXT,
text_var2 = PG_EXCEPTION_DETAIL,
text_var3 = PG_EXCEPTION_HINT;
END;