Is is possible to call a plpgsql function (or any PostgreSQL function) from a PL/Python function?
So, something like this:
CREATE FUNCTION somefunc() RETURNS void AS $$
DECLARE
...
BEGIN
...
END;
$$ LANGUAGE plpgsql;
And then use it here
CREATE FUNCTION pythonFunc() RETURNS void AS $$
...
someFunc() #postgreSQL function
...
$$ LANGUAGE plpythonu;
asked Jan 24, 2017 at 11:22
four-eyes
12.8k37 gold badges135 silver badges259 bronze badges
1 Answer 1
create function plpython_function()
returns void as $$
plpy.execute('select plpgsql_function()')
$$ language plpythonu;
answered Jan 24, 2017 at 11:48
Clodoaldo Neto
127k30 gold badges251 silver badges274 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
PhilHibbs
How would you pass arguments on from the plpython_function to the plpgsql_function? The short answer to this would be, "import plpy and use plpy.quote_literal". My reply to that would be, "that's all very well, but 8.2 (actually, Greenplum) does not have plpy.quote_literal, it is actually quote_literal that I want to call!" Bootstrap problem.
default