How can I create a function that shows only the OID of the connected user? In this case you only have to display the number 10 when calling the function
postgres=# select current_user;
current_user
--------------
postgres
(1 fila)
In this case you only have to display the number 10 when calling the function
CodePudding user response:
You can look it up in pg_roles
:
CREATE FUNCTION current_userid() RETURNS oid
STABLE PARALLEL SAFE LANGUAGE sql AS
'SELECT oid FROM pg_roles WHERE rolname = current_user';