如果你创建一个像这样的普通旧函数:
CREATE OR REPLACE FUNCTION foo(p_bar_i IN VARCHAR2) RETURNS VARCHAR2 IS BEGIN RETURN p_bar_i || 'baz'; END; /
您可以轻松地在sqlalchemy
中调用它:
q = session.query(func.foo(MyTable.hello))
# or
sel = select([func.foo(my_table.c.hello)])
如何从SQLAlchemy调用包内定义的函数,如下所示:
CREATE PACKAGE master IS FUNCTION foo(p_bar_i IN VARCHAR2) RETURNS VARCHAR2; END; / CREATE PACKAGE BODY master IS FUNCTION foo(p_bar_i IN VARCHAR2) RETURNS VARCHAR IS BEGIN RETURN p_bar_i || 'baz'; END; END; /