7

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;

1 Answer 1

9
create function plpython_function()
returns void as $$

    plpy.execute('select plpgsql_function()')

$$ language plpythonu;

PL/Python Database Access

Sign up to request clarification or add additional context in comments.

1 Comment

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.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.