Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call plpgsql Function from a PL/Python Function in PostgreSQL

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;
like image 243
Stophface Avatar asked Jan 24 '17 11:01

Stophface


1 Answers

create function plpython_function()
returns void as $$

    plpy.execute('select plpgsql_function()')

$$ language plpythonu;

PL/Python Database Access

like image 170
Clodoaldo Neto Avatar answered Nov 11 '22 02:11

Clodoaldo Neto