My question is this: Why do some postgresql functions require an empty bracket and others don't and how can I tell the correct syntax?
Examples: This does not work
select pg_postmaster_start_time;
results in
ERROR: column "pg_postmaster_start_time" does not exist
LINE 1: select pg_postmaster_start_time;
^
However this works:
select pg_postmaster_start_time();
resulting in
pg_postmaster_start_time
-------------------------------
2016-08-01 16:07:12.728306+01
(1 row)
Now for the converse case: This works
select current_user;
and it results in
current_user
--------------
edbstore
(1 row)
But this does not work
select current_user();
Resulting in
ERROR: syntax error at or near "("
LINE 1: select current_user();
^
I did find this has been asked here, but there didn't seem to be an answer
Read docs - it says
Note: current_catalog, current_schema, current_user, session_user, and user have special syntactic status in SQL: they must be called without trailing parentheses. (In PostgreSQL, parentheses can optionally be used with current_schema, but not with the others.)
I know it sounds like "because it says so", so does not actually answer your question. But this is how docs explain it.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments