Is it possible to get the current OID within a function? Like:
CREATE FUNCTION foo()
RETURNS numeric
LANGUAGE plpgsql
AS '
BEGIN
return THIS_FUNCTIONS_OID;
END
';
I need this, because I created function foo
within different schemas so the functions name is not helpful here.
I guess you are looking smth like
return select oid from pg_proc where proname='$0';
I doubt you can get it as variable. You can get the name from current_query()
, but it will be very not reliable... Unless you define function name as first argument each time you call it :), then you can use $1, but it is not much reliable either...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With